dbuenzli / cmarkit

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

Inconsistent Commonmark escaping for number followed by dot (e.g. `1.`) #11

Closed 3Rafal closed 11 months ago

3Rafal commented 1 year ago

As seen in example below, 1. is rendered to 1\\..

utop # let inline = Inline.Text ("1.", Cmarkit.Meta.none);;
val inline : Cmarkit.Inline.t = Cmarkit.Inline.Text ("1.", <abstr>)
utop # let paragraph = Block.Paragraph.make inline;;
val paragraph : Block.Paragraph.t = <abstr>
utop # let bp = Block.Paragraph (paragraph, Meta.none);;
val bp : Block.t = Cmarkit.Block.Paragraph (<abstr>, <abstr>)
utop # let doc  = Doc.make bp;;
val doc : Doc.t = <abstr>
utop # Cmarkit_commonmark.of_doc doc;;
- : string = "1\\."

However, the same procedure for 2. will render just 2.. As I understand it, the code for this behavior is: https://github.com/dbuenzli/cmarkit/blob/f37c8ea86fd0be8dba7a8babcee3682e0e047d91/src/cmarkit_commonmark.ml#L74-L75

I would assume that this escaping should work for all number+dot combinations.

See en example of similar problem shown in a different commonmark implementation: https://github.com/thephpleague/commonmark/blob/795851fa43b6981f7e751ae714788078075b2bbb/tests/benchmark/sample.md?plain=1#L450

dbuenzli commented 1 year ago

Not sure exactly what went into my head when I did that. It's even documented.