Markdown scoped links
=====================

[[Parent]]: markdown_syntax.txt

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
-------

[[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

History
-------

The [region extension][Region] 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.

[Region]: [[Ref]]: markdown_region.txt
[BugReport]: https://github.com/waylan/Python-Markdown/issues/406
