Skip to content

feature proposal: add support for internal links #900

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Overdr0ne
Copy link

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

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, and
navigate them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant