mirror of
https://gitea.com/gitea/tea.git
synced 2025-12-19 21:02:12 +01:00
Update Dependencies (#390)
Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: Norwin <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/390 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
7
vendor/github.com/yuin/goldmark/README.md
generated
vendored
7
vendor/github.com/yuin/goldmark/README.md
generated
vendored
@@ -8,7 +8,7 @@ goldmark
|
||||
|
||||
> A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured.
|
||||
|
||||
goldmark is compliant with CommonMark 0.29.
|
||||
goldmark is compliant with CommonMark 0.30.
|
||||
|
||||
Motivation
|
||||
----------------------
|
||||
@@ -280,7 +280,7 @@ markdown := goldmark.New(
|
||||
[]byte("https:"),
|
||||
}),
|
||||
extension.WithLinkifyURLRegexp(
|
||||
xurls.Strict(),
|
||||
xurls.Strict,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -303,7 +303,7 @@ This extension has some options:
|
||||
| `extension.WithFootnoteBacklinkClass` | `[]byte` | a class for footnote backlinks. This defaults to `footnote-backref`. |
|
||||
| `extension.WithFootnoteBacklinkHTML` | `[]byte` | a class for footnote backlinks. This defaults to `↩︎`. |
|
||||
|
||||
Some options can have special substitutions. Occurances of “^^” in the string will be replaced by the corresponding footnote number in the HTML output. Occurances of “%%” will be replaced by a number for the reference (footnotes can have multiple references).
|
||||
Some options can have special substitutions. Occurrences of “^^” in the string will be replaced by the corresponding footnote number in the HTML output. Occurrences of “%%” will be replaced by a number for the reference (footnotes can have multiple references).
|
||||
|
||||
`extension.WithFootnoteIDPrefix` and `extension.WithFootnoteIDPrefixFunction` are useful if you have multiple Markdown documents displayed inside one HTML document to avoid footnote ids to clash each other.
|
||||
|
||||
@@ -423,6 +423,7 @@ Extensions
|
||||
- [goldmark-emoji](https://github.com/yuin/goldmark-emoji): An emoji
|
||||
extension for the goldmark Markdown parser.
|
||||
- [goldmark-mathjax](https://github.com/litao91/goldmark-mathjax): Mathjax support for the goldmark markdown parser
|
||||
- [goldmark-pdf](https://github.com/stephenafamo/goldmark-pdf): A PDF renderer that can be passed to `goldmark.WithRenderer()`.
|
||||
|
||||
goldmark internal(for extension developers)
|
||||
----------------------------------------------
|
||||
|
||||
4
vendor/github.com/yuin/goldmark/ast/block.go
generated
vendored
4
vendor/github.com/yuin/goldmark/ast/block.go
generated
vendored
@@ -332,7 +332,7 @@ type List struct {
|
||||
Marker byte
|
||||
|
||||
// IsTight is a true if this list is a 'tight' list.
|
||||
// See https://spec.commonmark.org/0.29/#loose for details.
|
||||
// See https://spec.commonmark.org/0.30/#loose for details.
|
||||
IsTight bool
|
||||
|
||||
// Start is an initial number of this ordered list.
|
||||
@@ -414,7 +414,7 @@ func NewListItem(offset int) *ListItem {
|
||||
}
|
||||
|
||||
// HTMLBlockType represents kinds of an html blocks.
|
||||
// See https://spec.commonmark.org/0.29/#html-blocks
|
||||
// See https://spec.commonmark.org/0.30/#html-blocks
|
||||
type HTMLBlockType int
|
||||
|
||||
const (
|
||||
|
||||
2
vendor/github.com/yuin/goldmark/ast/inline.go
generated
vendored
2
vendor/github.com/yuin/goldmark/ast/inline.go
generated
vendored
@@ -111,7 +111,7 @@ func (n *Text) SetRaw(v bool) {
|
||||
}
|
||||
|
||||
// HardLineBreak returns true if this node ends with a hard line break.
|
||||
// See https://spec.commonmark.org/0.29/#hard-line-breaks for details.
|
||||
// See https://spec.commonmark.org/0.30/#hard-line-breaks for details.
|
||||
func (n *Text) HardLineBreak() bool {
|
||||
return n.flags&textHardLineBreak != 0
|
||||
}
|
||||
|
||||
2
vendor/github.com/yuin/goldmark/extension/definition_list.go
generated
vendored
2
vendor/github.com/yuin/goldmark/extension/definition_list.go
generated
vendored
@@ -138,7 +138,7 @@ func (b *definitionDescriptionParser) Open(parent gast.Node, reader text.Reader,
|
||||
para.Parent().RemoveChild(para.Parent(), para)
|
||||
}
|
||||
cpos, padding := util.IndentPosition(line[pos+1:], pos+1, list.Offset-pos-1)
|
||||
reader.AdvanceAndSetPadding(cpos, padding)
|
||||
reader.AdvanceAndSetPadding(cpos+1, padding)
|
||||
|
||||
return ast.NewDefinitionDescription(), parser.HasChildren
|
||||
}
|
||||
|
||||
2
vendor/github.com/yuin/goldmark/extension/footnote.go
generated
vendored
2
vendor/github.com/yuin/goldmark/extension/footnote.go
generated
vendored
@@ -539,7 +539,7 @@ func (r *FootnoteHTMLRenderer) renderFootnoteBacklink(w util.BufWriter, source [
|
||||
if entering {
|
||||
n := node.(*ast.FootnoteBacklink)
|
||||
is := strconv.Itoa(n.Index)
|
||||
_, _ = w.WriteString(` <a href="#`)
|
||||
_, _ = w.WriteString(` <a href="#`)
|
||||
_, _ = w.Write(r.idPrefix(node))
|
||||
_, _ = w.WriteString(`fnref:`)
|
||||
_, _ = w.WriteString(is)
|
||||
|
||||
24
vendor/github.com/yuin/goldmark/extension/linkify.go
generated
vendored
24
vendor/github.com/yuin/goldmark/extension/linkify.go
generated
vendored
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/yuin/goldmark/util"
|
||||
)
|
||||
|
||||
var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]+(?:[/#?][-a-zA-Z0-9@:%_\+.~#!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
|
||||
var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?:[/#?][-a-zA-Z0-9@:%_\+.~#!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
|
||||
|
||||
var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]+(?::\d+)?(?:[/#?][-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
|
||||
var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?::\d+)?(?:[/#?][-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
|
||||
|
||||
// An LinkifyConfig struct is a data structure that holds configuration of the
|
||||
// Linkify extension.
|
||||
@@ -24,10 +24,12 @@ type LinkifyConfig struct {
|
||||
EmailRegexp *regexp.Regexp
|
||||
}
|
||||
|
||||
const optLinkifyAllowedProtocols parser.OptionName = "LinkifyAllowedProtocols"
|
||||
const optLinkifyURLRegexp parser.OptionName = "LinkifyURLRegexp"
|
||||
const optLinkifyWWWRegexp parser.OptionName = "LinkifyWWWRegexp"
|
||||
const optLinkifyEmailRegexp parser.OptionName = "LinkifyEmailRegexp"
|
||||
const (
|
||||
optLinkifyAllowedProtocols parser.OptionName = "LinkifyAllowedProtocols"
|
||||
optLinkifyURLRegexp parser.OptionName = "LinkifyURLRegexp"
|
||||
optLinkifyWWWRegexp parser.OptionName = "LinkifyWWWRegexp"
|
||||
optLinkifyEmailRegexp parser.OptionName = "LinkifyEmailRegexp"
|
||||
)
|
||||
|
||||
// SetOption implements SetOptioner.
|
||||
func (c *LinkifyConfig) SetOption(name parser.OptionName, value interface{}) {
|
||||
@@ -156,10 +158,12 @@ func (s *linkifyParser) Trigger() []byte {
|
||||
return []byte{' ', '*', '_', '~', '('}
|
||||
}
|
||||
|
||||
var protoHTTP = []byte("http:")
|
||||
var protoHTTPS = []byte("https:")
|
||||
var protoFTP = []byte("ftp:")
|
||||
var domainWWW = []byte("www.")
|
||||
var (
|
||||
protoHTTP = []byte("http:")
|
||||
protoHTTPS = []byte("https:")
|
||||
protoFTP = []byte("ftp:")
|
||||
domainWWW = []byte("www.")
|
||||
)
|
||||
|
||||
func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
|
||||
if pc.IsInLinkLabel() {
|
||||
|
||||
41
vendor/github.com/yuin/goldmark/extension/table.go
generated
vendored
41
vendor/github.com/yuin/goldmark/extension/table.go
generated
vendored
@@ -18,8 +18,9 @@ import (
|
||||
var escapedPipeCellListKey = parser.NewContextKey()
|
||||
|
||||
type escapedPipeCell struct {
|
||||
Cell *ast.TableCell
|
||||
Pos []int
|
||||
Cell *ast.TableCell
|
||||
Pos []int
|
||||
Transformed bool
|
||||
}
|
||||
|
||||
// TableCellAlignMethod indicates how are table cells aligned in HTML format.indicates how are table cells aligned in HTML format.
|
||||
@@ -216,7 +217,7 @@ func (b *tableParagraphTransformer) parseRow(segment text.Segment, alignments []
|
||||
break
|
||||
} else if hasBacktick {
|
||||
if escapedCell == nil {
|
||||
escapedCell = &escapedPipeCell{node, []int{}}
|
||||
escapedCell = &escapedPipeCell{node, []int{}, false}
|
||||
escapedList := pc.ComputeIfAbsent(escapedPipeCellListKey,
|
||||
func() interface{} {
|
||||
return []*escapedPipeCell{}
|
||||
@@ -288,22 +289,34 @@ func (a *tableASTTransformer) Transform(node *gast.Document, reader text.Reader,
|
||||
}
|
||||
pc.Set(escapedPipeCellListKey, nil)
|
||||
for _, v := range lst.([]*escapedPipeCell) {
|
||||
if v.Transformed {
|
||||
continue
|
||||
}
|
||||
_ = gast.Walk(v.Cell, func(n gast.Node, entering bool) (gast.WalkStatus, error) {
|
||||
if n.Kind() != gast.KindCodeSpan {
|
||||
if !entering || n.Kind() != gast.KindCodeSpan {
|
||||
return gast.WalkContinue, nil
|
||||
}
|
||||
c := n.FirstChild()
|
||||
for c != nil {
|
||||
|
||||
for c := n.FirstChild(); c != nil; {
|
||||
next := c.NextSibling()
|
||||
if c.Kind() == gast.KindText {
|
||||
t := c.(*gast.Text)
|
||||
if c.Kind() != gast.KindText {
|
||||
c = next
|
||||
continue
|
||||
}
|
||||
parent := c.Parent()
|
||||
ts := &c.(*gast.Text).Segment
|
||||
n := c
|
||||
for _, v := range lst.([]*escapedPipeCell) {
|
||||
for _, pos := range v.Pos {
|
||||
if t.Segment.Start <= pos && t.Segment.Stop > pos {
|
||||
n1 := gast.NewRawTextSegment(t.Segment.WithStop(pos))
|
||||
n2 := gast.NewRawTextSegment(t.Segment.WithStart(pos + 1))
|
||||
n.InsertAfter(n, c, n1)
|
||||
n.InsertAfter(n, n1, n2)
|
||||
n.RemoveChild(n, c)
|
||||
if ts.Start <= pos && pos < ts.Stop {
|
||||
segment := n.(*gast.Text).Segment
|
||||
n1 := gast.NewRawTextSegment(segment.WithStop(pos))
|
||||
n2 := gast.NewRawTextSegment(segment.WithStart(pos + 1))
|
||||
parent.InsertAfter(parent, n, n1)
|
||||
parent.InsertAfter(parent, n1, n2)
|
||||
parent.RemoveChild(parent, n)
|
||||
n = n2
|
||||
v.Transformed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/github.com/yuin/goldmark/parser/attribute.go
generated
vendored
11
vendor/github.com/yuin/goldmark/parser/attribute.go
generated
vendored
@@ -89,7 +89,11 @@ func parseAttribute(reader text.Reader) (Attribute, bool) {
|
||||
reader.Advance(1)
|
||||
line, _ := reader.PeekLine()
|
||||
i := 0
|
||||
for ; i < len(line) && !util.IsSpace(line[i]) && (!util.IsPunct(line[i]) || line[i] == '_' || line[i] == '-'); i++ {
|
||||
// HTML5 allows any kind of characters as id, but XHTML restricts characters for id.
|
||||
// CommonMark is basically defined for XHTML(even though it is legacy).
|
||||
// So we restrict id characters.
|
||||
for ; i < len(line) && !util.IsSpace(line[i]) &&
|
||||
(!util.IsPunct(line[i]) || line[i] == '_' || line[i] == '-' || line[i] == ':' || line[i] == '.'); i++ {
|
||||
}
|
||||
name := attrNameClass
|
||||
if c == '#' {
|
||||
@@ -129,6 +133,11 @@ func parseAttribute(reader text.Reader) (Attribute, bool) {
|
||||
if !ok {
|
||||
return Attribute{}, false
|
||||
}
|
||||
if bytes.Equal(name, attrNameClass) {
|
||||
if _, ok = value.([]byte); !ok {
|
||||
return Attribute{}, false
|
||||
}
|
||||
}
|
||||
return Attribute{Name: name, Value: value}, true
|
||||
}
|
||||
|
||||
|
||||
17
vendor/github.com/yuin/goldmark/parser/code_block.go
generated
vendored
17
vendor/github.com/yuin/goldmark/parser/code_block.go
generated
vendored
@@ -49,6 +49,12 @@ func (b *codeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context
|
||||
}
|
||||
reader.AdvanceAndSetPadding(pos, padding)
|
||||
_, segment = reader.PeekLine()
|
||||
|
||||
// if code block line starts with a tab, keep a tab as it is.
|
||||
if segment.Padding != 0 {
|
||||
preserveLeadingTabInCodeBlock(&segment, reader, 0)
|
||||
}
|
||||
|
||||
node.Lines().Append(segment)
|
||||
reader.Advance(segment.Len() - 1)
|
||||
return Continue | NoChildren
|
||||
@@ -77,3 +83,14 @@ func (b *codeBlockParser) CanInterruptParagraph() bool {
|
||||
func (b *codeBlockParser) CanAcceptIndentedLine() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func preserveLeadingTabInCodeBlock(segment *text.Segment, reader text.Reader, indent int) {
|
||||
offsetWithPadding := reader.LineOffset() + indent
|
||||
sl, ss := reader.Position()
|
||||
reader.SetPosition(sl, text.NewSegment(ss.Start-1, ss.Stop))
|
||||
if offsetWithPadding == reader.LineOffset() {
|
||||
segment.Padding = 0
|
||||
segment.Start--
|
||||
}
|
||||
reader.SetPosition(sl, ss)
|
||||
}
|
||||
|
||||
4
vendor/github.com/yuin/goldmark/parser/delimiter.go
generated
vendored
4
vendor/github.com/yuin/goldmark/parser/delimiter.go
generated
vendored
@@ -30,11 +30,11 @@ type Delimiter struct {
|
||||
Segment text.Segment
|
||||
|
||||
// CanOpen is set true if this delimiter can open a span for a new node.
|
||||
// See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
|
||||
// See https://spec.commonmark.org/0.30/#can-open-emphasis for details.
|
||||
CanOpen bool
|
||||
|
||||
// CanClose is set true if this delimiter can close a span for a new node.
|
||||
// See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
|
||||
// See https://spec.commonmark.org/0.30/#can-open-emphasis for details.
|
||||
CanClose bool
|
||||
|
||||
// Length is a remaining length of this delimiter.
|
||||
|
||||
5
vendor/github.com/yuin/goldmark/parser/fcode_block.go
generated
vendored
5
vendor/github.com/yuin/goldmark/parser/fcode_block.go
generated
vendored
@@ -71,6 +71,7 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con
|
||||
func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
|
||||
line, segment := reader.PeekLine()
|
||||
fdata := pc.Get(fencedCodeBlockInfoKey).(*fenceData)
|
||||
|
||||
w, pos := util.IndentWidth(line, reader.LineOffset())
|
||||
if w < 4 {
|
||||
i := pos
|
||||
@@ -89,6 +90,10 @@ func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc C
|
||||
pos, padding := util.DedentPositionPadding(line, reader.LineOffset(), segment.Padding, fdata.indent)
|
||||
|
||||
seg := text.NewSegmentPadding(segment.Start+pos, segment.Stop, padding)
|
||||
// if code block line starts with a tab, keep a tab as it is.
|
||||
if padding != 0 {
|
||||
preserveLeadingTabInCodeBlock(&seg, reader, fdata.indent)
|
||||
}
|
||||
node.Lines().Append(seg)
|
||||
reader.AdvanceAndSetPadding(segment.Stop-segment.Start-pos-1, padding)
|
||||
return Continue | NoChildren
|
||||
|
||||
4
vendor/github.com/yuin/goldmark/parser/html_block.go
generated
vendored
4
vendor/github.com/yuin/goldmark/parser/html_block.go
generated
vendored
@@ -76,8 +76,8 @@ var allowedBlockTags = map[string]bool{
|
||||
"ul": true,
|
||||
}
|
||||
|
||||
var htmlBlockType1OpenRegexp = regexp.MustCompile(`(?i)^[ ]{0,3}<(script|pre|style)(?:\s.*|>.*|/>.*|)\n?$`)
|
||||
var htmlBlockType1CloseRegexp = regexp.MustCompile(`(?i)^.*</(?:script|pre|style)>.*`)
|
||||
var htmlBlockType1OpenRegexp = regexp.MustCompile(`(?i)^[ ]{0,3}<(script|pre|style|textarea)(?:\s.*|>.*|/>.*|)\n?$`)
|
||||
var htmlBlockType1CloseRegexp = regexp.MustCompile(`(?i)^.*</(?:script|pre|style|textarea)>.*`)
|
||||
|
||||
var htmlBlockType2OpenRegexp = regexp.MustCompile(`^[ ]{0,3}<!\-\-`)
|
||||
var htmlBlockType2Close = []byte{'-', '-', '>'}
|
||||
|
||||
2
vendor/github.com/yuin/goldmark/parser/list.go
generated
vendored
2
vendor/github.com/yuin/goldmark/parser/list.go
generated
vendored
@@ -164,6 +164,8 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
|
||||
if node.ChildCount() == 1 && node.LastChild().ChildCount() == 0 {
|
||||
return Close
|
||||
}
|
||||
|
||||
reader.Advance(len(line)-1)
|
||||
return Continue | HasChildren
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/yuin/goldmark/parser/list_item.go
generated
vendored
2
vendor/github.com/yuin/goldmark/parser/list_item.go
generated
vendored
@@ -53,6 +53,8 @@ func (b *listItemParser) Open(parent ast.Node, reader text.Reader, pc Context) (
|
||||
func (b *listItemParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
|
||||
line, _ := reader.PeekLine()
|
||||
if util.IsBlank(line) {
|
||||
reader.Advance(len(line) - 1)
|
||||
|
||||
return Continue | HasChildren
|
||||
}
|
||||
|
||||
|
||||
16
vendor/github.com/yuin/goldmark/parser/parser.go
generated
vendored
16
vendor/github.com/yuin/goldmark/parser/parser.go
generated
vendored
@@ -1129,21 +1129,27 @@ func (p *parser) parseBlock(block text.BlockReader, parent ast.Node, pc Context)
|
||||
break
|
||||
}
|
||||
lineLength := len(line)
|
||||
softLinebreak := false
|
||||
hardlineBreak := false
|
||||
softLinebreak := line[lineLength-1] == '\n'
|
||||
if lineLength >= 2 && line[lineLength-2] == '\\' && softLinebreak { // ends with \\n
|
||||
hasNewLine := line[lineLength-1] == '\n'
|
||||
if lineLength >= 2 && line[lineLength-2] == '\\' && hasNewLine { // ends with \\n
|
||||
lineLength -= 2
|
||||
hardlineBreak = true
|
||||
|
||||
} else if lineLength >= 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && softLinebreak { // ends with \\r\n
|
||||
} else if lineLength >= 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && hasNewLine { // ends with \\r\n
|
||||
lineLength -= 3
|
||||
hardlineBreak = true
|
||||
} else if lineLength >= 3 && line[lineLength-3] == ' ' && line[lineLength-2] == ' ' && softLinebreak { // ends with [space][space]\n
|
||||
} else if lineLength >= 3 && line[lineLength-3] == ' ' && line[lineLength-2] == ' ' && hasNewLine { // ends with [space][space]\n
|
||||
lineLength -= 3
|
||||
hardlineBreak = true
|
||||
} else if lineLength >= 4 && line[lineLength-4] == ' ' && line[lineLength-3] == ' ' && line[lineLength-2] == '\r' && softLinebreak { // ends with [space][space]\r\n
|
||||
} else if lineLength >= 4 && line[lineLength-4] == ' ' && line[lineLength-3] == ' ' && line[lineLength-2] == '\r' && hasNewLine { // ends with [space][space]\r\n
|
||||
lineLength -= 4
|
||||
hardlineBreak = true
|
||||
} else if hasNewLine {
|
||||
// If the line ends with a newline character, but it is not a hardlineBreak, then it is a softLinebreak
|
||||
// If the line ends with a hardlineBreak, then it cannot end with a softLinebreak
|
||||
// See https://spec.commonmark.org/0.30/#soft-line-breaks
|
||||
softLinebreak = true
|
||||
}
|
||||
|
||||
l, startPosition := block.Position()
|
||||
|
||||
1
vendor/github.com/yuin/goldmark/renderer/html/html.go
generated
vendored
1
vendor/github.com/yuin/goldmark/renderer/html/html.go
generated
vendored
@@ -318,6 +318,7 @@ func (r *Renderer) renderHTMLBlock(w util.BufWriter, source []byte, node ast.Nod
|
||||
var ListAttributeFilter = GlobalAttributeFilter.Extend(
|
||||
[]byte("start"),
|
||||
[]byte("reversed"),
|
||||
[]byte("type"),
|
||||
)
|
||||
|
||||
func (r *Renderer) renderList(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||
|
||||
Reference in New Issue
Block a user