You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I sent a PR to take a look at. One question I have is, how should the following be handled:
a: [^b]
[^b]: * a
* b
* c
d
Here we have a conflict between two rules: the footnote should be closed by one blank line, but the list (which is inside the footnote) is closed by two. With the code in the PR, the list [a, b] is inside the footnote def, while c gets its own list. This seems reasonable but I want to think about whether it's truly the best behavior.
Alternatively (since the spec doesn't nail this down), we can dictate that footnotes and lists are both consistently ended by two blank lines.
I (personally) don't see this as a bug. If you look in specs/footnote.txt, multi-paragraph footnotes are deliberately supported, and footnotes are already ended on two blank lines.
multi-paragraph footnotes are deliberately supported
I see... I did not "expect" that (or lists) in footnotes. Generally, footnotes are a single paragraph of text.
since the spec doesn't nail this down
If we are going to take the route of making footnotes end with a single blank line (which is probably what most people might expect, and markdown is about being intuitive, right?), then deny lists inside it (for consistency in number of blank lines). I'm against it because it will look kinda ugly if footnote definitions (containing lists) are rendered as a numeric list (as in wikipedia).
Footnote definitions are container blocks which cannot be defined within another container.
> reference[^b].
>
> [^b]: but this is not a valid footnote definition
A footnote definition can be indented with at most 3 spaces.
[^b]: footnote text
If a sequence of blocks should be contained within a footnote definition, indent it to align with the first non-whitespace character in the definition body.
[^b]: * list item1 inside footnote
* list item2 inside footnote
* list item outside footnote
The footnote definition continues as long as the indentation matches (or exceeds):
[^b]: * list item1 inside footnote
* list item2 inside footnote
still inside footnote
For convenience, the definition body can start in the next line too, with a non-zero indentation (at least N+2 spaces, 0≤N≤3 is the initial indentation):
[^long-footnote-name]:
inside footnote
* list item inside footnote
outside footnote
The definition body cannot start in the next line without the minimum indentation. The following should be treated as an empty footnote definition:
FWIW, the reason the spec acts the way it does is because, whatever is most common in writing contexts, multi-paragraph footnotes are a genuine need. (I have from time to time used them myself.) Just as importantly in many ways, pretty much all existing implementations with footnote support treat footnotes as a(n indented) block type, which allows them to have multiple paragraphs within them. So whatever is most purely "intuitive" may not be what's best in this case.
It looks like this footnote spec is homegrown rather than part of the CommonMark spec. How open is it for change?
I would not have expected list item b to be part of the [^b] footnote definition at all.
It appears as though a footnote definition should treated as a container block -- all indications in this thread are that footnotes are expected to support multiple paragraphs, lists, and other blocks.
If a footnote definition is a container block, it should act very much like list items do in CommonMark. Continuing lines in a footnote definition should be indented to the same level as the first non-whitespace character after the [^b]: item. The rules to end a list item should apply to a footnote definition.
Is there an argument against treating footnotes as an additional type of container block similar to a list item?
Which can be generated if there is a blank line between footnote definitions. Is this intentional too?
It appears to be intentional as that is covered specifically by a test case in the footnotes.txt spec. I would have expected your example to be two separate footnote definitions if I hadn't read that spec first.
Was this footnote spec copied from somewhere or just made for this program?
After going through the spec for lists once again, and keeping the goal to maximize intuitiveness, I rewrote the spec I proposed earlier (in-place). Please take a look. I tried to make it consistent with the current style of specs.
[^long-footnote-name]:
inside footnote
* list item inside footnote
outside footnote
With the footnote identifier change to a list item marker would be all one list item due to lazy continuation rules. The "outside footnote" text would be part of the "list item inside footnote" (see here)
Considering your second example as a list item rather than a footnote, it seems fine. However, this version should probably all be one footnote due to laziness:
[^b]: text
inside footnote
This version with the subsequent line indented to one space beyond the footnote marker should probably be just like a list item starting with a blank line:
[^b]:
inside footnote
I agree with your third example.
It seems like the one place this still differs from list items is dealing with a long footnote name. Subsequent blocks inside a list item (except in the case of laziness) need to be indented as far as the first non-whitespace character after the list marker. If the footnote name is very long, this could be impractical.
I think the discussion starting with "Would it help to adopt a two-space rule?" under 5.2.1 Motivation in the CommonMark spec may be relevant here.
Perhaps a two-space rule can be justified by something like "The [^ is the footnote definition indicator, so everything should be indented past that." Not sure. Seems a little messy still.
Looking at the proposed spec here, and this one is probably not quite right:
If a sequence of blocks should be contained within a footnote definition, indent it to align with the first non-whitespace character in the definition body.
[^b]: * list item1 inside footnote
* list item2 inside footnote
* list item outside footnote
The indentation rule here is unnecessarily different from the rules for other container types. Most of them allow this variation instead
A paragraph of text to host a footnote.[^b][^b]: Here is a paragraph in the footnote, and then a list.
* list item1 inside footnote
* list item2 inside footnote
* list item outside footnote
<p>A paragraph of text to host a footnote.<ahref="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p><ul><li>list item outside footnote</li></ul><sectionclass="footnotes" role="doc-endnotes"><hr/><ol><liid="fn1" role="doc-endnote"><p>Here is a paragraph in the footnote, and then a list.</p><ul><li>list item1 inside footnote</li><li>list item2 inside footnote</li></ul><ahref="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></li></ol></section>
That is, roughly (given the limitations of GH's HTML rendering):
What's more, it renders the same regardless of the amount you indent within the block as long as there is no end to the contained block—for example, with a list immediately following.
Without suggesting that Pandoc's implementation is normative, it's nonetheless fairly representative. There's some variation on the treatment of the * list item outside footnote bit in other implementations, as well as on what indentation is required. Pandoc footnotes don’t require indentation at all as long as there is no double-newline ending the block. Most other implementations I’m aware of do require indentation, of whatever size is required to start/continue a new block child in the implementation generally.
That means rule 3 should actually be something like:
If a sequence of blocks should be contained within a footnote definition, indent it as a block continuation (the same as continuing a list).
[^fn-def]:
* list item1 inside footnote
* list item2 inside footnote
* list item outside footnote
This could/should be a bit more precise: it would be best to match up that indentation rule with the normal block continuation rules from the CommonMark spec.
Note for folks following this thread: I am (albeit very slowly) working my way toward a solution to alllll the footnote issues over on #544. Honestly, it’ll likely be the end of the year before I have something working (at earliest!) but I really, really want “standard” footnotes to just work in pulldown-cmark, so I’m going to keep pushing on it, however slowly.
[^1]: My reference.
[^2]: To add line breaks within a footnote, prefix new lines with 2 spaces.
This is a second line.
...and renders multiple footnote definitions in a group incompatible with Prettier, which collapses away any blank lines you manually insert between them and likely will insist that you're in the wrong if you don't bow to their decision that different Markdown dialects must have non-standard extensions.
(At least, that was their opinion when I asked for a config option to support how Doxygen draws semantic distinctions between certain synonymous Markdown constructs that Prettier currently normalizes.)
...as such, I can't currently use footnotes in any context where more than one definition is grouped together in sequence because my Prettier-on-save will induce pulldown-cmark to produce corrupted output.
Activity
raphlinus commentedon Apr 10, 2016
I sent a PR to take a look at. One question I have is, how should the following be handled:
Here we have a conflict between two rules: the footnote should be closed by one blank line, but the list (which is inside the footnote) is closed by two. With the code in the PR, the list [a, b] is inside the footnote def, while c gets its own list. This seems reasonable but I want to think about whether it's truly the best behavior.
Alternatively (since the spec doesn't nail this down), we can dictate that footnotes and lists are both consistently ended by two blank lines.
notriddle commentedon Apr 10, 2016
I (personally) don't see this as a bug. If you look in
specs/footnote.txt, multi-paragraph footnotes are deliberately supported, and footnotes are already ended on two blank lines.critiqjo commentedon Apr 10, 2016
I see... I did not "expect" that (or lists) in footnotes. Generally, footnotes are a single paragraph of text.
If we are going to take the route of making footnotes end with a single blank line (which is probably what most people might expect, and markdown is about being intuitive, right?), then deny lists inside it (for consistency in number of blank lines). I'm against it because it will look kinda ugly if footnote definitions (containing lists) are rendered as a numeric list (as in wikipedia).
critiqjo commentedon Apr 11, 2016
Spec for multi-block footnote-definitions.
Footnote definitions are container blocks which cannot be defined within another container.
A footnote definition can be indented with at most 3 spaces.
If a sequence of blocks should be contained within a footnote definition, indent it to align with the first non-whitespace character in the definition body.
The footnote definition continues as long as the indentation matches (or exceeds):
For convenience, the definition body can start in the next line too, with a non-zero indentation (at least N+2 spaces, 0≤N≤3 is the initial indentation):
The definition body cannot start in the next line without the minimum indentation. The following should be treated as an empty footnote definition:
Laziness with paragraph continuation:
UPDATE (2017-03-30): Simplify
UPDATE (2017-03-31): Better consistency
chriskrycho commentedon May 2, 2016
FWIW, the reason the spec acts the way it does is because, whatever is most common in writing contexts, multi-paragraph footnotes are a genuine need. (I have from time to time used them myself.) Just as importantly in many ways, pretty much all existing implementations with footnote support treat footnotes as a(n indented) block type, which allows them to have multiple paragraphs within them. So whatever is most purely "intuitive" may not be what's best in this case.
ScottAbbey commentedon Mar 30, 2017
Regarding the list within footnote issue above:
This appears to have changed between CommonMark 0.26 and 0.27.
0.26:
0.27:
So it is clear that the
clist item must in all cases be a part of the list that contains theblist item.ScottAbbey commentedon Mar 30, 2017
Follow-up from #21 (comment):
It looks like this footnote spec is homegrown rather than part of the CommonMark spec. How open is it for change?
I would not have expected list item
bto be part of the[^b]footnote definition at all.It appears as though a footnote definition should treated as a container block -- all indications in this thread are that footnotes are expected to support multiple paragraphs, lists, and other blocks.
If a footnote definition is a container block, it should act very much like list items do in CommonMark. Continuing lines in a footnote definition should be indented to the same level as the first non-whitespace character after the
[^b]:item. The rules to end a list item should apply to a footnote definition.Is there an argument against treating footnotes as an additional type of container block similar to a list item?
critiqjo commentedon Mar 30, 2017
The following text:
Generates:
Instead of:
Which can be generated if there is a blank line between footnote definitions. Is this intentional too?
ScottAbbey commentedon Mar 30, 2017
It appears to be intentional as that is covered specifically by a test case in the footnotes.txt spec. I would have expected your example to be two separate footnote definitions if I hadn't read that spec first.
Was this footnote spec copied from somewhere or just made for this program?
notriddle commentedon Mar 30, 2017
I just made it up.
critiqjo commentedon Mar 30, 2017
After going through the spec for lists once again, and keeping the goal to maximize intuitiveness, I rewrote the spec I proposed earlier (in-place). Please take a look. I tried to make it consistent with the current style of specs.
ScottAbbey commentedon Mar 30, 2017
This example:
With the footnote identifier change to a list item marker would be all one list item due to lazy continuation rules. The "outside footnote" text would be part of the "list item inside footnote" (see here)
Considering your second example as a list item rather than a footnote, it seems fine. However, this version should probably all be one footnote due to laziness:
This version with the subsequent line indented to one space beyond the footnote marker should probably be just like a list item starting with a blank line:
I agree with your third example.
It seems like the one place this still differs from list items is dealing with a long footnote name. Subsequent blocks inside a list item (except in the case of laziness) need to be indented as far as the first non-whitespace character after the list marker. If the footnote name is very long, this could be impractical.
I think the discussion starting with "Would it help to adopt a two-space rule?" under 5.2.1 Motivation in the CommonMark spec may be relevant here.
Perhaps a two-space rule can be justified by something like "The
[^is the footnote definition indicator, so everything should be indented past that." Not sure. Seems a little messy still.critiqjo commentedon Mar 31, 2017
@ScottAbbey You're right, that's indeed an inconsistency. I'll update the proposal soon.
UPDATE: Updated
oberien commentedon Aug 4, 2018
What's the status on this? I just ran into this problem with the following reference-list:
This generates the following events, which make the parser not being able to find the link definition and instead calls the broken_link_callback:
chriskrycho commentedon Sep 17, 2021
Looking at the proposed spec here, and this one is probably not quite right:
The indentation rule here is unnecessarily different from the rules for other container types. Most of them allow this variation instead
This is how pandoc renders it
That is, roughly (given the limitations of GH's HTML rendering):
What's more, it renders the same regardless of the amount you indent within the block as long as there is no end to the contained block—for example, with a list immediately following.
Without suggesting that Pandoc's implementation is normative, it's nonetheless fairly representative. There's some variation on the treatment of the
* list item outside footnotebit in other implementations, as well as on what indentation is required. Pandoc footnotes don’t require indentation at all as long as there is no double-newline ending the block. Most other implementations I’m aware of do require indentation, of whatever size is required to start/continue a new block child in the implementation generally.That means rule 3 should actually be something like:
This could/should be a bit more precise: it would be best to match up that indentation rule with the normal block continuation rules from the CommonMark spec.
chriskrycho commentedon Nov 20, 2021
Note for folks following this thread: I am (albeit very slowly) working my way toward a solution to alllll the footnote issues over on #544. Honestly, it’ll likely be the end of the year before I have something working (at earliest!) but I really, really want “standard” footnotes to just work in pulldown-cmark, so I’m going to keep pushing on it, however slowly.
ssokolow commentedon Apr 6, 2023
It also breaks this example from GitHub's GFM docs...
...and renders multiple footnote definitions in a group incompatible with Prettier, which collapses away any blank lines you manually insert between them and likely will insist that you're in the wrong if you don't bow to their decision that different Markdown dialects must have non-standard extensions.
(At least, that was their opinion when I asked for a config option to support how Doxygen draws semantic distinctions between certain synonymous Markdown constructs that Prettier currently normalizes.)
...as such, I can't currently use footnotes in any context where more than one definition is grouped together in sequence because my Prettier-on-save will induce pulldown-cmark to produce corrupted output.
ShaunSHamilton commentedon Apr 14, 2023
This one stumped me for a long time. I really hope there will be a fix at some point.
Currently, I have to:
Which would be fine, except it adds a lot of spacing in the resultant HTML
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does
Add a separate mode to parse footnotes the same way GitHub does