B.nana Technology Log in

Markdown Links

A Python Markdown extension that adds special handling of Markdown links to Markdown content.

Markdown Links is open source and hosted on GitHub at https://github.com/binokkio/markdown_links. A packaged version is available on PyPI and can be installed with pip install markdown-links.

Examples

Linked content title

Markdown Links can take the title from the linked document and/or content. It does this by resolving the link relative to the current working directory and reading the file. If the link does not point to a local Markdown file, it will do nothing, allowing the normal Markdown link handling to kick in.

Markdown: [](../markdownup/index.md)
Result: MarkdownUp

Markdown: [](../markdownup/index.md#main-features)
Result: Main features

Markdown: []+(../markdownup/index.md#main-features)
Result: Main features (MarkdownUp)

Markdown: [Custom title]+(../markdownup/index.md)
Result: Custom title (MarkdownUp)

The green color comes from markdown_links.css, which is included in the PyPI package and can be modified as desired.

Linked content primer

Markdown Links considers the "primer" to be the first line of text in the linked content.

Markdown: [](../markdownup/index.md)+
Result: MarkdownUp: Serves Markdown as HTML.

Markdown: [](../markdownup/index.md)+Custom primer.+
Result: MarkdownUp: Custom primer.

Linked content excerpt, foldable

Markdown: [](../markdownup/index.md)"Main features">0
Result: MarkdownUp

If the link is in a place where only phrasing content is allowed, the foldable excerpt will be placed after the link parent end-tag. Therefore the link can be in the middle of a paragraph and the excerpt will be displayed after the paragraph. The quotes can be left empty if an anchor is present in the href:

Markdown: See [](index.md#importance)"">1 for the meaning of the number.
Result: See Importance for the meaning of the number.

Linked content excerpt, list item

This relies on markdown_links.css, which is included in the PyPI package.

Markdown:

- [](../markdownup/index.md)"Main features"<1
- [Custom title]+(../markdownup/index.md)+"Main features"<0
- []+(../markdownup/index.md#main-features)+Custom primer.+""<0

Result:

See Importance for the meaning of the number at the end of the Markdown Links syntax.

Excerpts

Importance

The number at the end of the Markdown Links syntax is interpreted as the excerpt importance. An importance of 0 means the excerpt will be folded/hidden on page load. An importance of 1 means it will be unfolded/shown on page load unless the excerpt is inside another excerpt. If the excerpt is inside one or more excerpts, the importance must be higher than the number of excerpts it is inside of for the excerpt to be unfolded/shown on page load.