markdown-mode
markdown-mode copied to clipboard
feature proposal: add support for internal links
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