# Footnote extensions vs Link Reference Definition

**URL:** <https://talk.commonmark.org/t/footnote-extensions-vs-link-reference-definition/2571>\
**Category:** Extensions\
**Created:** [August 14, 2017, 7:59am UTC](https://talk.commonmark.org/t/footnote-extensions-vs-link-reference-definition/2571 "2017-08-14T07:59:35Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Crissov](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/crissov/32/1455_2.png) [@Crissov](https://talk.commonmark.org/u/Crissov)\
**Post date:** [December 18, 2017, 12:41pm UTC](https://talk.commonmark.org/t/footnote-extensions-vs-link-reference-definition/2571/9 "2017-12-18T12:41:05Z")

</div>

Babelmark 3 currently interfaces with “GitHub Flavored Markdown”, i.e. cmark-gfm, version 0.17.4, which does not seem to have this extension enabled yet.

[GitHub’s documentation `extensions.txt`](https://github.com/github/cmark/blob/master/test/extensions.txt) should probably be written more like `spec.txt`. It is missing several edge cases right now.

Anyway, I did not really get the point of this thread. No other implementation seems to support Pandoc’s inline footnotes with a circumflex preceding bracketed text, `^[footnote]`, and automatically generated mark. MMD will turn the link label `[^footnote]` into inline footnote text if it cannot be resolved to a reference link definition.

Many existing implementations largely agree with CM about [_link labels_](http://spec.commonmark.org/0.28/#link-label) which start with a circumflex, so will try to turn them into links. If the respective reference link definition only contains a single string without whitespace, it will be used as the URL. I believe CM could be prepared better for extensions if reference link definitions were slightly changed: the _link destination_ should be optional when a _link title_ (in parentheses, single or double quotation marks) follows (or possibly any part of an _info string_ that cannot be interpreted as the destination URL). However, feeding empty or degenerate URLs did not have the expected results in CM-compatible implementations and some others – at least unless I separate the ill-formed link definitions from the rest by blank lines.

An extension or postprocessor that hooks into the AST could simply check whether the first character of `<text>` within `<link>` is `^` and then modify it accordingly. This also avoid stuff like parsing the destination `#` as the start of a heading, which is something that happens in several implementations that support footnotes. Link titles, which become footnote texts, do not support blank lines inside and thus no paragraphs, but may contain inline formatting.

A minor drawback perhaps, the original location of the link definition will be lost already at this point, so all notes will necessarily be automatically placed at either the (page) foot or the (document) end.

[Babelmark 3](https://babelmark.github.io/?text=Single+word%5B%5E1%5D++%0AMultiple+words%5B%5E2%5D++%0AQuoted+words%5B%5E3%5D++%0AHash+URL%5B%5E4%5D++%0ADot+URL%5B%5E5%5D++%0AEmpty+URL%5B%5E6%5D++%0A%0A%5B%5E1%5D%3A+Note%0A%0A%5B%5E2%5D%3A+several+words%0A%0A%5B%5E3%5D%3A+%22quoted+text%22%0A%0A%5B%5E4%5D%3A+%23+%22link+title+or+heading%22%0A%0A%5B%5E5%5D%3A+.+%22link+title%22%0A%0A%5B%5E6%5D%3A+%3C%3E+%22link+title%22%0A)  
[Dingus](http://spec.commonmark.org/dingus/?text=Single%20word%5B%5E1%5D%20%20%0AMultiple%20words%5B%5E2%5D%20%20%0AQuoted%20words%5B%5E3%5D%20%20%0AHash%20URL%5B%5E4%5D%20%20%0ADot%20URL%5B%5E5%5D%20%20%0AEmpty%20URL%5B%5E6%5D%20%20%0AURL%5B%5E7%5D%20%20%0A%0A%5B%5E1%5D%3A%20Note%0A%0A%5B%5E2%5D%3A%20several%20words%0A%0A%5B%5E3%5D%3A%20%22quoted%20text%22%0A%0A%5B%5E4%5D%3A%20%23%20%22link%20title%20or%20heading%22%0A%0A%5B%5E5%5D%3A%20.%20%22link%20title%22%0A%0A%5B%5E6%5D%3A%20%3C%3E%20%22link%20title%22%0A%0A%5B%5E7%5D%3A%20destination%20%22link%20title%22)

PS: The reference implementations do not agree about empty URLs inside angle brackets:

```
[label]: <> "title"

```

> A [link destination](http://spec.commonmark.org/0.28/#link-destination) consists of either
> 
> - a sequence of zero or more characters between an opening `<` and a closing `>` …

---

_[View the full topic](https://talk.commonmark.org/t/footnote-extensions-vs-link-reference-definition/2571)._
