Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions html/callouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ bliep bliep
t.Error("callout code block not correctly parsed")
}
}

func TestEscapeHTMLCalloutsMultipleComments(t *testing.T) {
code := []byte(`a //<<1>>
b #<<2>>
c <<9>>
`)
out := `a <span class="callout">1</span>
b <span class="callout">2</span>
c &lt;&lt;9&gt;&gt;
`
orders := [][][]byte{
{[]byte("//"), []byte("#")},
{[]byte("#"), []byte("//")},
}
for _, comments := range orders {
buf := &bytes.Buffer{}
opts := RendererOptions{}
opts.Comments = comments
NewRenderer(opts).EscapeHTMLCallouts(buf, code)
if buf.String() != out {
t.Errorf("comments=%q\ngot:\n%s\nwant:\n%s", comments, buf.String(), out)
}
}
}
3 changes: 2 additions & 1 deletion html/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,9 @@ func (r *Renderer) EscapeHTMLCallouts(w io.Writer, d []byte) {
Parse:
for i := 0; i < ld; i++ {
for _, comment := range r.Opts.Comments {
// try every configured marker, not just the first
if !bytes.HasPrefix(d[i:], comment) {
break
continue
}

lc := len(comment)
Expand Down