diff --git a/_test/extra.txt b/_test/extra.txt index 374d622..09c1a5d 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -703,3 +703,11 @@ This line will be displayed. //- - - - - - - - -//

\\\ufffd"

//= = = = = = = = = = = = = = = = = = = = = = = =// + + +55: inline HTML comment +//- - - - - - - - -// +a c +//- - - - - - - - -// +

a c

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/raw_html.go b/parser/raw_html.go index afd6f58..133c906 100644 --- a/parser/raw_html.go +++ b/parser/raw_html.go @@ -81,9 +81,12 @@ func (s *rawHTMLParser) parseComment(block text.Reader, pc Context) ast.Node { line = line[offset:] for { hindex := bytes.Index(line, doubleHyphen) + if hindex > -1 { + hindex += offset + } index := bytes.Index(line, closeComment) + offset if index > -1 && hindex == index { - if index == 0 || line[index-1] != '-' { + if index == 0 || len(line) < 2 || line[index-1] != '-' { node.Segments.Append(segment.WithStop(segment.Start + index + len(closeComment))) block.Advance(index + len(closeComment)) return node