Skip to content
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

Footnote in a footnote appears before other footnotes #410

Open
1 of 3 tasks
kuruczgy opened this issue Aug 23, 2023 · 6 comments
Open
1 of 3 tasks

Footnote in a footnote appears before other footnotes #410

kuruczgy opened this issue Aug 23, 2023 · 6 comments
Labels
pinned issue should not be closed by stalebot

Comments

@kuruczgy
Copy link

goldmark has https://github.com/yuin/goldmark/discussions in github.
You should post only issues here. Feature requests and questions should be posted at discussions.

  • goldmark is fully compliant with the CommonMark. Before submitting issue, you must read CommonMark spec and confirm your output is different from CommonMark online demo.
    • Extensions(Autolink without < >, Table, etc) are not part of CommonMark spec. You should confirm your output is different from other official renderers correspond with an extension.
  • goldmark is not dedicated for Hugo. If you are Hugo user and your issue was raised by your experience in Hugo, you should consider create issue at Hugo repository at first .

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : goldmark: v1.5.4, https://github.com/kpym/gm: v0.11.4
  2. What version of Go are you using? : go version go1.21.0 linux/amd64
  3. What operating system and processor architecture are you using? : linux/amd64
  4. What did you do? : gm test.md
    Where test.md contains:
before[^before]

[^before]: before

parent[^parent]

[^parent]: parent[^child]

[^child]: child

after[^after]

[^after]: after
  1. What did you expect to see? : Using https://michelf.ca/projects/php-markdown/dingus/, the order of the footnotes is:
1. before
2. parent
3. after
4. child
  1. What did you see instead? :
    The order the footnotes appear in index.html is the following:
1. before
2. child
3. parent
4. after
  1. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: Yes, see above.
@kuruczgy
Copy link
Author

kuruczgy commented Aug 23, 2023

Workaround for anyone finding this issue:

diff --git a/extension/footnote.go b/extension/footnote.go
index d1b67aa..b856d92 100644
--- a/extension/footnote.go
+++ b/extension/footnote.go
@@ -91,8 +91,8 @@ func (b *footnoteBlockParser) Close(node gast.Node, reader text.Reader, pc parse
 	} else {
 		list = ast.NewFootnoteList()
 		pc.Set(footnoteListKey, list)
-		node.Parent().InsertBefore(node.Parent(), node, list)
 	}
+	node.Parent().InsertBefore(node.Parent(), node, list)
 	node.Parent().RemoveChild(node.Parent(), node)
 	list.AppendChild(list, node)
 }

This solution seems kind of janky to me though, so I didn't want to submit it as a PR without prior discussion.

Also, the ideal order IMO would be before parent child after (which is what GitHub seems to do), but achieving that probably requires some additional logic.

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Sep 22, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Oct 6, 2023
@yuin yuin reopened this Oct 8, 2023
@github-actions github-actions bot removed the stale label Oct 9, 2023
Copy link

github-actions bot commented Nov 9, 2023

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Nov 9, 2023
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@yuin yuin reopened this Nov 23, 2023
@yuin yuin added pinned issue should not be closed by stalebot and removed stale labels Nov 23, 2023
@mwat56
Copy link

mwat56 commented Mar 15, 2024

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned issue should not be closed by stalebot
Projects
None yet
Development

No branches or pull requests

3 participants