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:
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()
|
||||
|
||||
Reference in New Issue
Block a user