-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Referencing a footnote multiple times lists the footnote once for each reference #241
Comments
It'd be really nice if this were fixed. I hate having a gazillion duplicate references, just because I chose to cite some info multiple times... Looks nasty and gross. |
@choueric What do you think? |
This looks like a valid issue, but it's not completely clear to me where the responsibility of de-duplicating footnotes lies. It's likely within scope of blackfriday, but needs to be considered. It doesn't seem anyone's actively working on it right now, so help is welcome. Some initial questions are... How does CommonMark specification deal with this situation? Has anything been done about this in |
From what I can tell, there is no proposed standardization for footnotes in the latest Commonmark spec: http://spec.commonmark.org/0.27/ That said, ordering and reuse of in-line references (i.e., footnotes) is critical in STM (scientific, technical, medical) publishing, so I hope this feature/fix is implemented soon. BTW, please consider this a belated thank you for putting together such a badass Markdown parser 😄 |
I can reproduce the problem both in v1 and v2. Tried to come up with a quick fix, but failed so far; the problem is quite entrenched. I'll keep digging. Here are the repro tests, in case anyone else wants to chime in: func TestRepro241(t *testing.T) {
tt := []string{
`This [^citation] is a sentence [^citation].
[^citation]: https://google.com/`,
"",
}
// TODO: test with HTML_FOOTNOTE_RETURN_LINKS
doTestsInlineParam(t, tt, Options{Extensions: EXTENSION_FOOTNOTES}, 0, HtmlRendererParameters{})
}
func TestReproCrash(t *testing.T) {
tt := []string{
"This describes[^recursion]\n\n[^recursion]: See Recursion[^recursion]",
"",
}
doTestsInlineParam(t, tt, Options{Extensions: EXTENSION_FOOTNOTES}, 0, HtmlRendererParameters{})
} |
@rtfb Any luck / are you still looking at it, or have you tabled it for now? |
Unfortunately, I couldn't find time for it. And I'm leaving for vacations in a few days, so unlikely to get back to it until end of June. If anyone's willing to give it a try, I'll be happy to review :-) For a recursion case, start looking at infinite loop resulting from repetitive calls to |
I think there is a straightforward way to fix it, which is adding a Because this infinite loop only happens when dealing with the footer, it can be avoided by not adding the existed link reference into There is another question: what's the proper text to replace the |
I checked the CI log and it is a failure of runing too long (10mins) for golang v1.2.2. The times of other versions are less than 10 minutes. I suppose it's not a coding problem ? |
fix duplicate and recursive footnotes. (#241)
Thanks to @choueric, this is now fixed. Give it a round of tests on v1 please (needs to be forward ported to v2). |
No, I added the corresponding PR (#366). Thanks for keeping an eye on it! |
Fix the infinite loop when there is a self-refer footnote by checking if the reference is already added into parser.notes. It also fixes of creating duplicate footnotes through this modification. Add coresponding testcase.
Originally posted here: gohugoio/hugo#1912
I don't know if this is intended or not (what would the return link do?), but I feel like duplicating the footnote is not the right way to go. The link even points to the uppermost footnote (instead of the one generated for this link).
An effect of this is if you try to reference the footnote itself in the footnote, Hugo crashes.
[^recursion]: See Recursion[^recursion]
output:
The text was updated successfully, but these errors were encountered: