-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add render option to wrap escaped chars in span #367
Add render option to wrap escaped chars in span #367
Conversation
This allows post-processing filters to know if a character was originally escaped or not. Normally that information is lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very very good, and super pleased to see things like sourcepos 100% correct. Thanks so much!
As an aside, I can't believe I didn't think of doing something like this back when I was at GitHub and contending with the exact same problem (then in cmark-gfm) — despite very much wanting to make backslash-escaping of @mentions a possibility, I simply couldn't think of a solution, and so |
Thanks! Yeah finally figured out a solution a couple years ago for GitLab, using pre-processing and post-processing filters, but it's a hack. So I'm quite stoked to be able to add this support natively! I just need to add some tests... |
println!("Original Input:"); | ||
println!("=============================="); | ||
println!("{}", original_input); | ||
println!("=============================="); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kivikakk added this so it's easier to see the original input that caused the error, rather than referring to the actual test.
with cargo run --example update-readme
This is fantastic! |
CommonMark supports escaping characters, which short-circuits normal markdown processing for that character.
But normally this information is lost in the final html. Post-processing filters sometimes need this information in order to keep special references from being recognized, such as
@user
. Ideally\@user
should keep the reference from being recognized, but the final html only has@user
.This PR adds an option
--escaped-char-spans
that will wrap escaped characters in a<span data-escaped-char>
. Post-processing filters can then use this when parsing for special references.