diff --git a/html/callouts_test.go b/html/callouts_test.go index 10124b9..b23f99b 100644 --- a/html/callouts_test.go +++ b/html/callouts_test.go @@ -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 1 +b 2 +c <<9>> +` + 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) + } + } +} diff --git a/html/renderer.go b/html/renderer.go index b3ee392..60ff7f7 100644 --- a/html/renderer.go +++ b/html/renderer.go @@ -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)