mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Bump up CommonMark Spec to 0.31.2
This commit is contained in:
parent
90c46e0829
commit
b8d6d3a9b7
5 changed files with 1610 additions and 1619 deletions
|
|
@ -8,7 +8,7 @@ goldmark
|
||||||
|
|
||||||
> A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured.
|
> A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured.
|
||||||
|
|
||||||
goldmark is compliant with CommonMark 0.30.
|
goldmark is compliant with CommonMark 0.31.2.
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
||||||
3184
_test/spec.json
3184
_test/spec.json
File diff suppressed because it is too large
Load diff
|
|
@ -61,8 +61,8 @@ var allowedBlockTags = map[string]bool{
|
||||||
"option": true,
|
"option": true,
|
||||||
"p": true,
|
"p": true,
|
||||||
"param": true,
|
"param": true,
|
||||||
|
"search": true,
|
||||||
"section": true,
|
"section": true,
|
||||||
"source": true,
|
|
||||||
"summary": true,
|
"summary": true,
|
||||||
"table": true,
|
"table": true,
|
||||||
"tbody": true,
|
"tbody": true,
|
||||||
|
|
|
||||||
|
|
@ -58,47 +58,38 @@ var closeProcessingInstruction = []byte("?>")
|
||||||
var openCDATA = []byte("<![CDATA[")
|
var openCDATA = []byte("<![CDATA[")
|
||||||
var closeCDATA = []byte("]]>")
|
var closeCDATA = []byte("]]>")
|
||||||
var closeDecl = []byte(">")
|
var closeDecl = []byte(">")
|
||||||
var emptyComment = []byte("<!---->")
|
var emptyComment1 = []byte("<!-->")
|
||||||
var invalidComment1 = []byte("<!-->")
|
var emptyComment2 = []byte("<!--->")
|
||||||
var invalidComment2 = []byte("<!--->")
|
|
||||||
var openComment = []byte("<!--")
|
var openComment = []byte("<!--")
|
||||||
var closeComment = []byte("-->")
|
var closeComment = []byte("-->")
|
||||||
var doubleHyphen = []byte("--")
|
|
||||||
|
|
||||||
func (s *rawHTMLParser) parseComment(block text.Reader, pc Context) ast.Node {
|
func (s *rawHTMLParser) parseComment(block text.Reader, pc Context) ast.Node {
|
||||||
savedLine, savedSegment := block.Position()
|
savedLine, savedSegment := block.Position()
|
||||||
node := ast.NewRawHTML()
|
node := ast.NewRawHTML()
|
||||||
line, segment := block.PeekLine()
|
line, segment := block.PeekLine()
|
||||||
if bytes.HasPrefix(line, emptyComment) {
|
if bytes.HasPrefix(line, emptyComment1) {
|
||||||
node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment)))
|
node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment1)))
|
||||||
block.Advance(len(emptyComment))
|
block.Advance(len(emptyComment1))
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
if bytes.HasPrefix(line, invalidComment1) || bytes.HasPrefix(line, invalidComment2) {
|
if bytes.HasPrefix(line, emptyComment2) {
|
||||||
return nil
|
node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment2)))
|
||||||
|
block.Advance(len(emptyComment2))
|
||||||
|
return node
|
||||||
}
|
}
|
||||||
offset := len(openComment)
|
offset := len(openComment)
|
||||||
line = line[offset:]
|
line = line[offset:]
|
||||||
for {
|
for {
|
||||||
hindex := bytes.Index(line, doubleHyphen)
|
index := bytes.Index(line, closeComment)
|
||||||
if hindex > -1 {
|
if index > -1 {
|
||||||
hindex += offset
|
node.Segments.Append(segment.WithStop(segment.Start + offset + index + len(closeComment)))
|
||||||
}
|
block.Advance(offset + index + len(closeComment))
|
||||||
index := bytes.Index(line, closeComment) + offset
|
return node
|
||||||
if index > -1 && hindex == index {
|
|
||||||
if index == 0 || len(line) < 2 || line[index-offset-1] != '-' {
|
|
||||||
node.Segments.Append(segment.WithStop(segment.Start + index + len(closeComment)))
|
|
||||||
block.Advance(index + len(closeComment))
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if hindex > 0 {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
offset = 0
|
||||||
node.Segments.Append(segment)
|
node.Segments.Append(segment)
|
||||||
block.AdvanceLine()
|
block.AdvanceLine()
|
||||||
line, segment = block.PeekLine()
|
line, segment = block.PeekLine()
|
||||||
offset = 0
|
|
||||||
if line == nil {
|
if line == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -808,7 +808,7 @@ func IsPunct(c byte) bool {
|
||||||
|
|
||||||
// IsPunctRune returns true if the given rune is a punctuation, otherwise false.
|
// IsPunctRune returns true if the given rune is a punctuation, otherwise false.
|
||||||
func IsPunctRune(r rune) bool {
|
func IsPunctRune(r rune) bool {
|
||||||
return int32(r) <= 256 && IsPunct(byte(r)) || unicode.IsPunct(r)
|
return unicode.IsSymbol(r) || unicode.IsPunct(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSpace returns true if the given character is a space, otherwise false.
|
// IsSpace returns true if the given character is a space, otherwise false.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue