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
Add support for Goldmark footnote render hooks #7427
Conversation
6495962
to
954bcc4
Compare
954bcc4
to
ecae209
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, I have a use case for custom footnote rendering that this will solve!
I have a couple minor suggestions around documentation, but overall the code looks solid. I don't fully understand the push/pop position stuff but the tests make me confident it works.
FYI, when I wrote documentation for the heading render hooks feature (#7133) I did it in https://github.com/gohugoio/hugoDocs (gohugoio/hugoDocs#1100). I don't really understand the relationship between that repo and this one though.
: The [Page](/variables/page/) being rendered. | ||
|
||
Index | ||
: The footnote numeric index (indicating which number footnote it is in order) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a zero-based index? (I'd assume so, but since the text content is 1-based I'd want to be sure)
@@ -94,6 +94,7 @@ The features currently supported are: | |||
* `image` | |||
* `link` | |||
* `heading` {{< new-in "0.71.0" >}} | |||
* `footnote-link` and `footnotes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add a {{< new-in
shortcode here, like in the heading
Sorry for the delay. Thanks for this. These render hooks are a little bit too heavy to enable for all kinds of Markdown elements. I thought long and hard before I added it for images and links, but those was kind of a must. I will close this down for now, we need to revisit this problem later. |
I'm hopefully this can be renewed. It would be very helpful for our use case. |
@bep I still think this would be really helpful, for a whole range of reasons, particularly for academic/scholar users of hugo. |
@bep I also think this would be really helpful. While shortcodes can accomplish a lot of things, I think it makes sense that when functionality is already provided by Goldmark, as footnotes are, render hooks should be provided. The academic use of footnotes is not a small use-case, and having to use relatively heavy shortcodes ( That said, as to this particular PR I think the default render hook should generate the same HTML as Goldmark, which from what I can see wraps the footnotes list in |
I want to vote for this feature! It's hard to customize the footnote area without using JS. I'm also a using this a lot in my writings, and I've also seen a lot of footnotes in the blogs I read about programming and research.
In my opinion, it's kind of confusing to close this PR without given an alternative approach. If this customization ability cannot be achieved without a hook, then how is it not a must?
Is there any further discussion on this? Maybe it's time to revisit it now? @bep Thanks! |
If #5087 can be implemented, then it's not a problem anymore, but that issue seems no progress as well.. |
This pull request will allow footnote/endnote customization with Goldmark via the footnote extension render hooks Goldmark provides.
I simplified the Hugo-side render hooks API from what Goldmark exposes and made the way they work for the Hugo end user much more idiomatic in terms of Hugo. There are just two new render templates: footnote-link (the superscript index in flow) and footnotes (all the notes at the bottom, ranged over)
See #7291
See #6807
See #6804