-
Notifications
You must be signed in to change notification settings - Fork 648
Update comrak to 0.2.3, use ext_header_ids #1129
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
Conversation
It occurs to me this won't quite fix #1023; the anchors still won't work because we prefix I'll come up with an appropriate solution shortly; on GitHub we use JavaScript which fires on hash change to search for and scroll to the item with the |
So, to prevent ID collisions, we'll also need to sanitize the IDs not coming from comrak-outputted header tags; I've proposed https://github.com/notriddle/ammonia/pull/66 (now merged!) to give us the machinery to do that. Finally, we'll need either the JavaScript portion to scroll the appropriate tag into view (I could throw this together easily based on what we're using here), or we'd need to change all relative |
This is so fragments are scrolled to on load.
The JavaScript side of the solution is now in this PR; ready for your thoughts/comments! |
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.
code looks good, going to try it out now :)
@@ -53,8 +53,7 @@ impl<'a> MarkdownRenderer<'a> { | |||
.cloned() | |||
.collect(); | |||
let tag_attributes = [ | |||
("a", ["href", "target"].iter().cloned().collect()), | |||
("code", ["class"].iter().cloned().collect()), |
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.
hm, does allowed_classes
make this line unnecessary...? I guess so since the tests pass!
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.
Indeed, it even became required in the newer ammonia
: https://github.com/notriddle/ammonia/blob/2581eec04ef98419fd202e0dd4d8997c9dfdb06e/src/lib.rs#L1030-L1037 (you're allowed to use allowed_classes
or set class
as an allowed tag, but not both)
Looks great, thank you!!! I'm going to review your other readme-related PRs then deploy and regenerate the readmes all at once, that'll probably take me a few days :) Thank you so much for taking care of all these things!!! bors: r+ |
Build succeeded |
Thanks so much! |
Fixes #1037. Use latest comrak, and use the header IDs extension to generate GitHub-compatible anchors.
/cc @kejadlen @treiff