Skip to content

Commit

Permalink
Fix #285
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Mar 8, 2022
1 parent a816d46 commit 0af2712
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions _test/extra.txt
Expand Up @@ -703,3 +703,11 @@ This line will be displayed.
//- - - - - - - - -//
<p>\\\ufffd&quot;</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//


55: inline HTML comment
//- - - - - - - - -//
a <!-- b --> c
//- - - - - - - - -//
<p>a <!-- b --> c</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
5 changes: 4 additions & 1 deletion parser/raw_html.go
Expand Up @@ -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
Expand Down

0 comments on commit 0af2712

Please sign in to comment.