dbuenzli / cmarkit

CommonMark parser and renderer for OCaml
https://erratique.ch/software/cmarkit
ISC License
46 stars 8 forks source link

CommonMark renderer doesn't escape tilde before strikethrough #20

Open tysg opened 8 months ago

tysg commented 8 months ago

Thank you for this great library.

utop # Cmarkit.Doc.of_string ~strict:false {|\~~~strike~~|} |> print_doc;;
Paragraph:
  Inlines:
    Text: '~'
    Strikethrough:
      Text: 'strike'

- : unit = ()
utop # Cmarkit.Doc.of_string ~strict:false {|\~~~strike~~|} |> Cmarkit_commonmark.of_doc;;
- : string = "~~~strike~~"

However, three tildes indicates the start of a fenced code block: commonmark.js preview. Reporting it here since it's not included in the known incorrect renderings list.

dbuenzli commented 8 months ago

Thanks.

Maybe the simplest is to unconditionally add ~ the set of characters that are unconditionally escaped at the start (first bullet here).

I suspect the same must be done for ` but I found another bug to be resolved first https://github.com/dbuenzli/cmarkit/issues/21