feature proposal: add support for internal links #900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Internal links allow users to link directly to sections within a document. These types of links are supported by most markdown parsers, and are part of the standard url format:
https://en.wikipedia.org/wiki/URL#Syntax
The URL standard refers to them as "fragments", but Emacs’ url library refers to them as "targets" so that’s the nomenclature used here. Notice also that link I referenced itself contains a fragment.
Markdown links may be "full" or "partial". "full" links are defined to contain the "type" in the URL standard. "Partial" links contain only the "fragment" component. Partial links are very useful for portability, but may not link between documents. Link fragments are generated through a standard normalization process, where a heading is downcased, stripped of punctuation, then kebab-cased. This means links are case and punctuation insensitive. Links also do not contain nesting information according to the standard. A later, alternate style of link could pretty easily resolve these shortcomings, but at the moment is not portable.
This changeset allows users to copy links to the kill ring:
copy-full-heading-link-at-point-as-kill
,copy-partial-heading-link-at-point-as-kill
Then navigate them with the usual
markdown-follow-link-at-point
I also went ahead and added a command to jump to headings directly, independent of links, which I found handy in the same way as a table of contents:
markdown-jump-to-heading