-
Notifications
You must be signed in to change notification settings - Fork 53
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
Rendering code replaces @xyz
with github link in URLs, breaking link targets
#204
Comments
Yeah, it's currently just some simple regexs. It might be worth breaking out a real markdown parser. |
It seems like comrak can be easily made to do what is needed... |
Mentoring instructionsThe linkifier code is part of the mdbook plugin. It can be found here: rust-project-goals/crates/mdbook-goals/src/mdbook_preprocessor.rs Lines 339 to 354 in 6255bff
It's pretty dumb. It iterates over regular expressions read from the TOML file and just blindly replaces them. Username replacement is similar, except the regular expression is hardcoded. rust-project-goals/crates/mdbook-goals/src/mdbook_preprocessor.rs Lines 271 to 294 in 6255bff
What I think we want to do is to use the comrak crate as described here to parse the markdown (presumably around here in the code). We would then apply the linkifiers, username substitution, and the other translations to the text nodes in the markdown rather than just applying it to the entire string. We MIGHT need to change from using The regular expression construction is here: rust-project-goals/crates/mdbook-goals/src/mdbook_preprocessor.rs Lines 72 to 88 in 6255bff
|
If you write something like
[this document](https://hackmd.org/@xyz/document)
, the rendering code will replace@xyz
with a github link, breaking the URL in the hackmd link.This replacement needs to be markdown-aware, and shouldn't happen in (at least) code blocks and link targets. If that's not easily possible, then we should disable the username-replacement logic until it can be fixed.
#203 was a PR that resulted from having to work around this breakage.
The text was updated successfully, but these errors were encountered: