Markdown scoped links

Back to Markdown syntax

A link-scope is a set of link-definitions. When a link is a defined in Remark, it is appended to the closest link-scope among its ancestor elements. Conversely, when a link is referenced, its definition is first searched from its closest link-scope, and on failure from ancestor link-scopes.

Remark extends Markdown with scoped links.

Elements with a link-scope

The following html-elements have their own link-scope.

<div>
A block.
<li>
A list-item.
<td>
A table-item.
<dd>
A definition.

Example

[A top-level link][1].

* [A local link with the same id][1].
    [1]: [[Ref: markdown_scoped_links.txt]]#liA
    * [Nested local link with the same id][1].
        [1]: [[Ref: markdown_scoped_links.txt]]#liAA
* [Another local link with the same id][1].
    [1]: [[Ref: markdown_scoped_links.txt]]#liB
* [Refer to the top-level link][1].

Homeostasis
: A state of psychological equilibrium obtained when tension or a drive has been reduced or eliminated. See [here][1].
    [1]: [[Ref: markdown_scoped_links.txt]]#dd

A | B | A + B
--|---|------
1 | 1 | 2
1 | 5 | 6 (See [here][1]) [1]: [[Ref: markdown_scoped_links.txt]]#td

[1]: [[Ref: markdown_scoped_links.txt]]#top

A top-level link.

Homeostasis
A state of psychological equilibrium obtained when tension or a drive has been reduced or eliminated. See here.
A B A + B
1 1 2
1 5 6 (See here)

History

The region extension extended Markdown with new kinds of blocks where it was natural for link-definitions to be embedded in them. Surprisingly, in April 2015, Python Markdown ignored link-definitions inside regions. This was because it only supported link-definitions at the global scope. According to the maintainer of Python Markdown, this was also the behavior in other Markdown parsers. Since he declared not wanting to implement scoped links, we wrote an extension ourselves.

Learn more

Files

Markdown scoped links extension