-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support anchored/reference links #47
Conversation
resolve_links now works TODO: - add tests - integrate into `to_xml()` with tryCatch() to avoid read errors - add documentation information
This will allow anchored links in the form of `[text][rel-link]` and [rel-link]: <URL> "Title" to be processed with the folowing caveats: 1. The URL is assumed to have no spaces 2. The anchor will sink to the bottom of the document (until we find a good process for re-introducing text nodes into the document).
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.
Brilliant as usual 🌟
protect_footnotes <- function(body, ns = md_ns()) { | ||
body <- copy_xml(body) | ||
|
||
feet <- footnote_check(body, ns) |
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.
🙂 🦶
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
I forgot to add an anchor to the link search, so a.com/ and a.com/b would both match a.com/, which resulted in an error. This also means that links with the same URLs and different titles will no longer match.
Sometimes you want to demonstrate links in markdown documents by protecting them with code blocks. This unfortunately creates a situation where a link matches twice and you need to choose. Since these links are not present in the XML in the first place, it's safe to choose a single link of the two that has sunk the furthest.
After a few false starts, I have run this against the suite of Software Carpentry lessons without error and I think I should be able to merge this now! |
Summary
This will allow anchored links in the form of
[text][rel-link]
and[rel-link]: <URL> "Title"
to be processed with the folowing caveats:good process for re-introducing text nodes into the document).
This will fix #45
Example
Without anchor link processing
With Anchor link processing
Created on 2021-05-24 by the reprex package (v2.0.0)