commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.62k stars 539 forks source link

Tracking backslash escapes? #450

Open zkamvar opened 1 year ago

zkamvar commented 1 year ago

I think this is similar/related to #131 and #292, but one thing I noticed is that bare square brackets do not roundtrip:

Input:

[unescaped brackets],  \[escaped brackets\] and [a link](https://example.com)

Output:

\[unescaped brackets\],  \[escaped brackets\] and [a link](https://example.com)

Is there a way to add an attribute that can track the position of escaped characters in a line?

This is useful for me because I'm trying to parse and rewrite documents that have reference links in child documents, and I have to backtrack to identify and protect these links from being overwritten.

(originally reported this in https://github.com/r-lib/commonmark/issues/20)