Model CommonMark's emphasis matching, and escape the delimiter that only closes #25

Merged
lilleman merged 3 commits from tick-2e5 into main 2026-08-27 13:17:36 +02:00
Owner

Flanking alone let two round-trip breaks through, both confirmed against cmark 0.31.2 and markdown-it 14.1.0: the multiple-of-3 rule took the em out of un*a**b*****c**istic, and a text delimiter that could only close stole the spelling around it (un*a* b*istic, ~~a~~ b~~).

The emitter now runs CommonMark's process_emphasis over the runs it wrote and carries a pair the matching hands to another delimiter; a delimiter run in text escapes wherever CommonMark could open or close with it, which keeps every delimiter the emitter did not write out of that matching. Canonical form gains a backslash where a run only closes.

2e5's own content lands with it: combined-document fixtures and the gate's collision property.

A brute-force emit-then-parse run over 143k generated paragraphs against both reference parsers: 4919 breaks before, 0 after.

Flanking alone let two round-trip breaks through, both confirmed against cmark 0.31.2 and markdown-it 14.1.0: the multiple-of-3 rule took the em out of `un*a**b*****c**istic`, and a text delimiter that could only close stole the spelling around it (`un*a* b*istic`, `~~a~~ b~~`). The emitter now runs CommonMark's process_emphasis over the runs it wrote and carries a pair the matching hands to another delimiter; a delimiter run in text escapes wherever CommonMark could open or close with it, which keeps every delimiter the emitter did not write out of that matching. Canonical form gains a backslash where a run only closes. 2e5's own content lands with it: combined-document fixtures and the gate's collision property. A brute-force emit-then-parse run over 143k generated paragraphs against both reference parsers: 4919 breaks before, 0 after.
lilleman added 1 commit 2026-08-27 12:43:01 +02:00
lilleman marked the pull request as work in progress 2026-08-27 12:43:19 +02:00
lilleman added 1 commit 2026-08-27 12:53:40 +02:00
lilleman added 1 commit 2026-08-27 13:17:11 +02:00
lilleman marked the pull request as ready for review 2026-08-27 13:17:24 +02:00
lilleman merged commit 82cf28f176 into main 2026-08-27 13:17:36 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: larvit/adf-codec#25