elements can have.
-var TableRowAttributeFilter = html.GlobalAttributeFilter.Extend(
- []byte("align"), // [Obsolete since HTML5]
- []byte("bgcolor"), // [Obsolete since HTML5]
- []byte("char"), // [Obsolete since HTML5]
- []byte("charoff"), // [Obsolete since HTML5]
- []byte("valign"), // [Obsolete since HTML5]
-)
-
-func (r *TableHTMLRenderer) renderTableRow(w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
- if entering {
- _, _ = w.WriteString("
\n")
- } else {
- _, _ = w.WriteString("
\n")
- if n.Parent().LastChild() == n {
- _, _ = w.WriteString("\n")
- }
- }
- return gast.WalkContinue, nil
-}
-
-// TableThCellAttributeFilter defines attribute names which table
cells can have.
-var TableThCellAttributeFilter = html.GlobalAttributeFilter.Extend(
- []byte("abbr"), // [OK] Contains a short abbreviated description of the cell's content [NOT OK in
]
-
- []byte("align"), // [Obsolete since HTML5]
- []byte("axis"), // [Obsolete since HTML5]
- []byte("bgcolor"), // [Not Standardized]
- []byte("char"), // [Obsolete since HTML5]
- []byte("charoff"), // [Obsolete since HTML5]
-
- []byte("colspan"), // [OK] Number of columns that the cell is to span
- []byte("headers"), // [OK] This attribute contains a list of space-separated strings, each corresponding to the id attribute of the
elements that apply to this element
-
- []byte("height"), // [Deprecated since HTML4] [Obsolete since HTML5]
-
- []byte("rowspan"), // [OK] Number of rows that the cell is to span
- []byte("scope"), // [OK] This enumerated attribute defines the cells that the header (defined in the
) element relates to [NOT OK in
]
-
- []byte("valign"), // [Obsolete since HTML5]
- []byte("width"), // [Deprecated since HTML4] [Obsolete since HTML5]
-)
-
-// TableTdCellAttributeFilter defines attribute names which table
cells can have.
-var TableTdCellAttributeFilter = html.GlobalAttributeFilter.Extend(
- []byte("abbr"), // [Obsolete since HTML5] [OK in
]
- []byte("align"), // [Obsolete since HTML5]
- []byte("axis"), // [Obsolete since HTML5]
- []byte("bgcolor"), // [Not Standardized]
- []byte("char"), // [Obsolete since HTML5]
- []byte("charoff"), // [Obsolete since HTML5]
-
- []byte("colspan"), // [OK] Number of columns that the cell is to span
- []byte("headers"), // [OK] This attribute contains a list of space-separated strings, each corresponding to the id attribute of the
elements that apply to this element
-
- []byte("height"), // [Deprecated since HTML4] [Obsolete since HTML5]
-
- []byte("rowspan"), // [OK] Number of rows that the cell is to span
-
- []byte("scope"), // [Obsolete since HTML5] [OK in
]
- []byte("valign"), // [Obsolete since HTML5]
- []byte("width"), // [Deprecated since HTML4] [Obsolete since HTML5]
-)
-
-func (r *TableHTMLRenderer) renderTableCell(w util.BufWriter, source []byte, node gast.Node, entering bool) (gast.WalkStatus, error) {
- n := node.(*ast.TableCell)
- tag := "td"
- if n.Parent().Kind() == ast.KindTableHeader {
- tag = "th"
- }
- if entering {
- fmt.Fprintf(w, "<%s", tag)
- if n.Alignment != ast.AlignNone {
- amethod := r.TableConfig.TableCellAlignMethod
- if amethod == TableCellAlignDefault {
- if r.Config.XHTML {
- amethod = TableCellAlignAttribute
- } else {
- amethod = TableCellAlignStyle
- }
- }
- switch amethod {
- case TableCellAlignAttribute:
- if _, ok := n.AttributeString("align"); !ok { // Skip align render if overridden
- fmt.Fprintf(w, ` align="%s"`, n.Alignment.String())
- }
- case TableCellAlignStyle:
- v, ok := n.AttributeString("style")
- var cob util.CopyOnWriteBuffer
- if ok {
- cob = util.NewCopyOnWriteBuffer(v.([]byte))
- cob.AppendByte(';')
- }
- style := fmt.Sprintf("text-align:%s", n.Alignment.String())
- cob.AppendString(style)
- n.SetAttributeString("style", cob.Bytes())
- }
- }
- if n.Attributes() != nil {
- if tag == "td" {
- html.RenderAttributes(w, n, TableTdCellAttributeFilter) //
- } else {
- html.RenderAttributes(w, n, TableThCellAttributeFilter) //
- }
- }
- _ = w.WriteByte('>')
- } else {
- fmt.Fprintf(w, "%s>\n", tag)
- }
- return gast.WalkContinue, nil
-}
-
-type table struct {
- options []TableOption
-}
-
-// Table is an extension that allow you to use GFM tables .
-var Table = &table{
- options: []TableOption{},
-}
-
-// NewTable returns a new extension with given options.
-func NewTable(opts ...TableOption) goldmark.Extender {
- return &table{
- options: opts,
- }
-}
-
-func (e *table) Extend(m goldmark.Markdown) {
- m.Parser().AddOptions(
- parser.WithParagraphTransformers(
- util.Prioritized(NewTableParagraphTransformer(), 200),
- ),
- parser.WithASTTransformers(
- util.Prioritized(defaultTableASTTransformer, 0),
- ),
- )
- m.Renderer().AddOptions(renderer.WithNodeRenderers(
- util.Prioritized(NewTableHTMLRenderer(e.options...), 500),
- ))
-}
diff --git a/vendor/github.com/yuin/goldmark/extension/tasklist.go b/vendor/github.com/yuin/goldmark/extension/tasklist.go
deleted file mode 100644
index 1f3e52c..0000000
--- a/vendor/github.com/yuin/goldmark/extension/tasklist.go
+++ /dev/null
@@ -1,115 +0,0 @@
-package extension
-
-import (
- "github.com/yuin/goldmark"
- gast "github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/extension/ast"
- "github.com/yuin/goldmark/parser"
- "github.com/yuin/goldmark/renderer"
- "github.com/yuin/goldmark/renderer/html"
- "github.com/yuin/goldmark/text"
- "github.com/yuin/goldmark/util"
- "regexp"
-)
-
-var taskListRegexp = regexp.MustCompile(`^\[([\sxX])\]\s*`)
-
-type taskCheckBoxParser struct {
-}
-
-var defaultTaskCheckBoxParser = &taskCheckBoxParser{}
-
-// NewTaskCheckBoxParser returns a new InlineParser that can parse
-// checkboxes in list items.
-// This parser must take precedence over the parser.LinkParser.
-func NewTaskCheckBoxParser() parser.InlineParser {
- return defaultTaskCheckBoxParser
-}
-
-func (s *taskCheckBoxParser) Trigger() []byte {
- return []byte{'['}
-}
-
-func (s *taskCheckBoxParser) Parse(parent gast.Node, block text.Reader, pc parser.Context) gast.Node {
- // Given AST structure must be like
- // - List
- // - ListItem : parent.Parent
- // - TextBlock : parent
- // (current line)
- if parent.Parent() == nil || parent.Parent().FirstChild() != parent {
- return nil
- }
-
- if _, ok := parent.Parent().(*gast.ListItem); !ok {
- return nil
- }
- line, _ := block.PeekLine()
- m := taskListRegexp.FindSubmatchIndex(line)
- if m == nil {
- return nil
- }
- value := line[m[2]:m[3]][0]
- block.Advance(m[1])
- checked := value == 'x' || value == 'X'
- return ast.NewTaskCheckBox(checked)
-}
-
-func (s *taskCheckBoxParser) CloseBlock(parent gast.Node, pc parser.Context) {
- // nothing to do
-}
-
-// TaskCheckBoxHTMLRenderer is a renderer.NodeRenderer implementation that
-// renders checkboxes in list items.
-type TaskCheckBoxHTMLRenderer struct {
- html.Config
-}
-
-// NewTaskCheckBoxHTMLRenderer returns a new TaskCheckBoxHTMLRenderer.
-func NewTaskCheckBoxHTMLRenderer(opts ...html.Option) renderer.NodeRenderer {
- r := &TaskCheckBoxHTMLRenderer{
- Config: html.NewConfig(),
- }
- for _, opt := range opts {
- opt.SetHTMLOption(&r.Config)
- }
- return r
-}
-
-// RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.
-func (r *TaskCheckBoxHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
- reg.Register(ast.KindTaskCheckBox, r.renderTaskCheckBox)
-}
-
-func (r *TaskCheckBoxHTMLRenderer) renderTaskCheckBox(w util.BufWriter, source []byte, node gast.Node, entering bool) (gast.WalkStatus, error) {
- if !entering {
- return gast.WalkContinue, nil
- }
- n := node.(*ast.TaskCheckBox)
-
- if n.IsChecked {
- w.WriteString(` ")
- } else {
- w.WriteString("> ")
- }
- return gast.WalkContinue, nil
-}
-
-type taskList struct {
-}
-
-// TaskList is an extension that allow you to use GFM task lists.
-var TaskList = &taskList{}
-
-func (e *taskList) Extend(m goldmark.Markdown) {
- m.Parser().AddOptions(parser.WithInlineParsers(
- util.Prioritized(NewTaskCheckBoxParser(), 0),
- ))
- m.Renderer().AddOptions(renderer.WithNodeRenderers(
- util.Prioritized(NewTaskCheckBoxHTMLRenderer(), 500),
- ))
-}
diff --git a/vendor/github.com/yuin/goldmark/extension/typographer.go b/vendor/github.com/yuin/goldmark/extension/typographer.go
deleted file mode 100644
index f56c06f..0000000
--- a/vendor/github.com/yuin/goldmark/extension/typographer.go
+++ /dev/null
@@ -1,339 +0,0 @@
-package extension
-
-import (
- "unicode"
-
- "github.com/yuin/goldmark"
- gast "github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/parser"
- "github.com/yuin/goldmark/text"
- "github.com/yuin/goldmark/util"
-)
-
-var uncloseCounterKey = parser.NewContextKey()
-
-type unclosedCounter struct {
- Single int
- Double int
-}
-
-func (u *unclosedCounter) Reset() {
- u.Single = 0
- u.Double = 0
-}
-
-func getUnclosedCounter(pc parser.Context) *unclosedCounter {
- v := pc.Get(uncloseCounterKey)
- if v == nil {
- v = &unclosedCounter{}
- pc.Set(uncloseCounterKey, v)
- }
- return v.(*unclosedCounter)
-}
-
-// TypographicPunctuation is a key of the punctuations that can be replaced with
-// typographic entities.
-type TypographicPunctuation int
-
-const (
- // LeftSingleQuote is '
- LeftSingleQuote TypographicPunctuation = iota + 1
- // RightSingleQuote is '
- RightSingleQuote
- // LeftDoubleQuote is "
- LeftDoubleQuote
- // RightDoubleQuote is "
- RightDoubleQuote
- // EnDash is --
- EnDash
- // EmDash is ---
- EmDash
- // Ellipsis is ...
- Ellipsis
- // LeftAngleQuote is <<
- LeftAngleQuote
- // RightAngleQuote is >>
- RightAngleQuote
- // Apostrophe is '
- Apostrophe
-
- typographicPunctuationMax
-)
-
-// An TypographerConfig struct is a data structure that holds configuration of the
-// Typographer extension.
-type TypographerConfig struct {
- Substitutions [][]byte
-}
-
-func newDefaultSubstitutions() [][]byte {
- replacements := make([][]byte, typographicPunctuationMax)
- replacements[LeftSingleQuote] = []byte("‘")
- replacements[RightSingleQuote] = []byte("’")
- replacements[LeftDoubleQuote] = []byte("“")
- replacements[RightDoubleQuote] = []byte("”")
- replacements[EnDash] = []byte("–")
- replacements[EmDash] = []byte("—")
- replacements[Ellipsis] = []byte("…")
- replacements[LeftAngleQuote] = []byte("«")
- replacements[RightAngleQuote] = []byte("»")
- replacements[Apostrophe] = []byte("’")
-
- return replacements
-}
-
-// SetOption implements SetOptioner.
-func (b *TypographerConfig) SetOption(name parser.OptionName, value interface{}) {
- switch name {
- case optTypographicSubstitutions:
- b.Substitutions = value.([][]byte)
- }
-}
-
-// A TypographerOption interface sets options for the TypographerParser.
-type TypographerOption interface {
- parser.Option
- SetTypographerOption(*TypographerConfig)
-}
-
-const optTypographicSubstitutions parser.OptionName = "TypographicSubstitutions"
-
-// TypographicSubstitutions is a list of the substitutions for the Typographer extension.
-type TypographicSubstitutions map[TypographicPunctuation][]byte
-
-type withTypographicSubstitutions struct {
- value [][]byte
-}
-
-func (o *withTypographicSubstitutions) SetParserOption(c *parser.Config) {
- c.Options[optTypographicSubstitutions] = o.value
-}
-
-func (o *withTypographicSubstitutions) SetTypographerOption(p *TypographerConfig) {
- p.Substitutions = o.value
-}
-
-// WithTypographicSubstitutions is a functional otpion that specify replacement text
-// for punctuations.
-func WithTypographicSubstitutions(values map[TypographicPunctuation][]byte) TypographerOption {
- replacements := newDefaultSubstitutions()
- for k, v := range values {
- replacements[k] = v
- }
-
- return &withTypographicSubstitutions{replacements}
-}
-
-type typographerDelimiterProcessor struct {
-}
-
-func (p *typographerDelimiterProcessor) IsDelimiter(b byte) bool {
- return b == '\'' || b == '"'
-}
-
-func (p *typographerDelimiterProcessor) CanOpenCloser(opener, closer *parser.Delimiter) bool {
- return opener.Char == closer.Char
-}
-
-func (p *typographerDelimiterProcessor) OnMatch(consumes int) gast.Node {
- return nil
-}
-
-var defaultTypographerDelimiterProcessor = &typographerDelimiterProcessor{}
-
-type typographerParser struct {
- TypographerConfig
-}
-
-// NewTypographerParser return a new InlineParser that parses
-// typographer expressions.
-func NewTypographerParser(opts ...TypographerOption) parser.InlineParser {
- p := &typographerParser{
- TypographerConfig: TypographerConfig{
- Substitutions: newDefaultSubstitutions(),
- },
- }
- for _, o := range opts {
- o.SetTypographerOption(&p.TypographerConfig)
- }
- return p
-}
-
-func (s *typographerParser) Trigger() []byte {
- return []byte{'\'', '"', '-', '.', ',', '<', '>', '*', '['}
-}
-
-func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser.Context) gast.Node {
- line, _ := block.PeekLine()
- c := line[0]
- if len(line) > 2 {
- if c == '-' {
- if s.Substitutions[EmDash] != nil && line[1] == '-' && line[2] == '-' { // ---
- node := gast.NewString(s.Substitutions[EmDash])
- node.SetCode(true)
- block.Advance(3)
- return node
- }
- } else if c == '.' {
- if s.Substitutions[Ellipsis] != nil && line[1] == '.' && line[2] == '.' { // ...
- node := gast.NewString(s.Substitutions[Ellipsis])
- node.SetCode(true)
- block.Advance(3)
- return node
- }
- return nil
- }
- }
- if len(line) > 1 {
- if c == '<' {
- if s.Substitutions[LeftAngleQuote] != nil && line[1] == '<' { // <<
- node := gast.NewString(s.Substitutions[LeftAngleQuote])
- node.SetCode(true)
- block.Advance(2)
- return node
- }
- return nil
- } else if c == '>' {
- if s.Substitutions[RightAngleQuote] != nil && line[1] == '>' { // >>
- node := gast.NewString(s.Substitutions[RightAngleQuote])
- node.SetCode(true)
- block.Advance(2)
- return node
- }
- return nil
- } else if s.Substitutions[EnDash] != nil && c == '-' && line[1] == '-' { // --
- node := gast.NewString(s.Substitutions[EnDash])
- node.SetCode(true)
- block.Advance(2)
- return node
- }
- }
- if c == '\'' || c == '"' {
- before := block.PrecendingCharacter()
- d := parser.ScanDelimiter(line, before, 1, defaultTypographerDelimiterProcessor)
- if d == nil {
- return nil
- }
- counter := getUnclosedCounter(pc)
- if c == '\'' {
- if s.Substitutions[Apostrophe] != nil {
- // Handle decade abbrevations such as '90s
- if d.CanOpen && !d.CanClose && len(line) > 3 && util.IsNumeric(line[1]) && util.IsNumeric(line[2]) && line[3] == 's' {
- after := rune(' ')
- if len(line) > 4 {
- after = util.ToRune(line, 4)
- }
- if len(line) == 3 || util.IsSpaceRune(after) || util.IsPunctRune(after) {
- node := gast.NewString(s.Substitutions[Apostrophe])
- node.SetCode(true)
- block.Advance(1)
- return node
- }
- }
- // special cases: 'twas, 'em, 'net
- if len(line) > 1 && (unicode.IsPunct(before) || unicode.IsSpace(before)) && (line[1] == 't' || line[1] == 'e' || line[1] == 'n' || line[1] == 'l') {
- node := gast.NewString(s.Substitutions[Apostrophe])
- node.SetCode(true)
- block.Advance(1)
- return node
- }
- // Convert normal apostrophes. This is probably more flexible than necessary but
- // converts any apostrophe in between two alphanumerics.
- if len(line) > 1 && (unicode.IsDigit(before) || unicode.IsLetter(before)) && (unicode.IsLetter(util.ToRune(line, 1))) {
- node := gast.NewString(s.Substitutions[Apostrophe])
- node.SetCode(true)
- block.Advance(1)
- return node
- }
- }
- if s.Substitutions[LeftSingleQuote] != nil && d.CanOpen && !d.CanClose {
- nt := LeftSingleQuote
- // special cases: Alice's, I'm, Don't, You'd
- if len(line) > 1 && (line[1] == 's' || line[1] == 'm' || line[1] == 't' || line[1] == 'd') && (len(line) < 3 || util.IsPunct(line[2]) || util.IsSpace(line[2])) {
- nt = RightSingleQuote
- }
- // special cases: I've, I'll, You're
- if len(line) > 2 && ((line[1] == 'v' && line[2] == 'e') || (line[1] == 'l' && line[2] == 'l') || (line[1] == 'r' && line[2] == 'e')) && (len(line) < 4 || util.IsPunct(line[3]) || util.IsSpace(line[3])) {
- nt = RightSingleQuote
- }
- if nt == LeftSingleQuote {
- counter.Single++
- }
-
- node := gast.NewString(s.Substitutions[nt])
- node.SetCode(true)
- block.Advance(1)
- return node
- }
- if s.Substitutions[RightSingleQuote] != nil {
- // plural possesives and abbreviations: Smiths', doin'
- if len(line) > 1 && unicode.IsSpace(util.ToRune(line, 0)) || unicode.IsPunct(util.ToRune(line, 0)) && (len(line) > 2 && !unicode.IsDigit(util.ToRune(line, 1))) {
- node := gast.NewString(s.Substitutions[RightSingleQuote])
- node.SetCode(true)
- block.Advance(1)
- return node
- }
- }
- if s.Substitutions[RightSingleQuote] != nil && counter.Single > 0 {
- isClose := d.CanClose && !d.CanOpen
- maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && unicode.IsPunct(util.ToRune(line, 1)) && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2])))
- if isClose || maybeClose {
- node := gast.NewString(s.Substitutions[RightSingleQuote])
- node.SetCode(true)
- block.Advance(1)
- counter.Single--
- return node
- }
- }
- }
- if c == '"' {
- if s.Substitutions[LeftDoubleQuote] != nil && d.CanOpen && !d.CanClose {
- node := gast.NewString(s.Substitutions[LeftDoubleQuote])
- node.SetCode(true)
- block.Advance(1)
- counter.Double++
- return node
- }
- if s.Substitutions[RightDoubleQuote] != nil && counter.Double > 0 {
- isClose := d.CanClose && !d.CanOpen
- maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && (unicode.IsPunct(util.ToRune(line, 1))) && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2])))
- if isClose || maybeClose {
- // special case: "Monitor 21""
- if len(line) > 1 && line[1] == '"' && unicode.IsDigit(before) {
- return nil
- }
- node := gast.NewString(s.Substitutions[RightDoubleQuote])
- node.SetCode(true)
- block.Advance(1)
- counter.Double--
- return node
- }
- }
- }
- }
- return nil
-}
-
-func (s *typographerParser) CloseBlock(parent gast.Node, pc parser.Context) {
- getUnclosedCounter(pc).Reset()
-}
-
-type typographer struct {
- options []TypographerOption
-}
-
-// Typographer is an extension that replaces punctuations with typographic entities.
-var Typographer = &typographer{}
-
-// NewTypographer returns a new Extender that replaces punctuations with typographic entities.
-func NewTypographer(opts ...TypographerOption) goldmark.Extender {
- return &typographer{
- options: opts,
- }
-}
-
-func (e *typographer) Extend(m goldmark.Markdown) {
- m.Parser().AddOptions(parser.WithInlineParsers(
- util.Prioritized(NewTypographerParser(e.options...), 9999),
- ))
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 0bef97d..58e97e4 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -2,7 +2,6 @@
## explicit; go 1.18
github.com/yuin/goldmark
github.com/yuin/goldmark/ast
-github.com/yuin/goldmark/extension
github.com/yuin/goldmark/extension/ast
github.com/yuin/goldmark/parser
github.com/yuin/goldmark/renderer