Repository navigation
Add MD_FLAG_ESCAPEDTEXT to report backslash-escaped characters - #477
Open
hryhoriiK97 wants to merge 1 commit into
Open
hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
hryhoriiK97
force-pushed
the
escaped-text
branch
from
October 31, 2026 14:58
09e2b98 to
4d55587
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #477 +/- ##
==========================================
+ Coverage 79.30% 79.32% +0.02%
==========================================
Files 5 5
Lines 3929 3933 +4
Branches 1311 1312 +1
==========================================
+ Hits 3116 3120 +4
Misses 295 295
Partials 518 518 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hryhoriiK97
force-pushed
the
escaped-text
branch
from
October 31, 2026 15:12
4d55587 to
6e41ad3
Compare
With the flag, a backslash-escaped character in normal text is reported as the new MD_TEXT_ESCAPED instead of MD_TEXT_NORMAL. The text is still the character without its backslash, so the HTML output does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
hryhoriiK97
force-pushed
the
escaped-text
branch
from
October 31, 2026 15:16
6e41ad3 to
c039cdd
Compare
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in
MD_FLAG_ESCAPEDTEXT. With it, a backslash-escaped character in normal text is reported as the newMD_TEXT_ESCAPEDinstead ofMD_TEXT_NORMAL. The text is still the character without its backslash, so a renderer that treats both types alike produces the same output, andmd4c-htmlneeds no change.Why
Once text reaches the callback, an application can't tell
\.from.. We hit this in react-native-enriched-markdown, which renders output from coding agents, where Windows paths in prose are common.C:\Users\me\.configrenders asC:\Users\me.config. That is correct CommonMark, but the application may know from context that the backslash was a separator and want to keep it.That decision belongs in the application, so this only exposes what the parser already knows. Syntax and spec behaviour don't change.
Flag bits and an alternative
I know flag bits are scarce (your comment on #429). Today an application can get the same answer without any parser change: an escaped character arrives as one byte pointing into the input, so it can count the backslashes right before that pointer. I tested this against the flag and they agreed on every escape, but it relies on behaviour the API doesn't document.
If you'd rather not spend a bit on this, documenting that guarantee in
md4c.hwould work for us too.Testing
Adds
test/spec-escaped-text.txt. The full suite passes, also under ASan and UBSan, and HTML output is identical with and without the flag across the spec files.