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

Add support for Goldmark footnote render hooks #7427

Closed

Conversation

samuelhorwitz
Copy link

@samuelhorwitz samuelhorwitz commented Jun 26, 2020

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

@samuelhorwitz samuelhorwitz force-pushed the custom-footnotes branch 4 times, most recently from 6495962 to 954bcc4 Compare June 27, 2020 16:52
Copy link
Contributor

@apexskier apexskier left a 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)
Copy link
Contributor

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`
Copy link
Contributor

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

@bep
Copy link
Member

bep commented Dec 2, 2020

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.

@bep bep closed this Dec 2, 2020
@swamidass
Copy link

I'm hopefully this can be renewed. It would be very helpful for our use case.

@swamidass
Copy link

@bep I still think this would be really helpful, for a whole range of reasons, particularly for academic/scholar users of hugo.

@rootwork
Copy link

@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 ({{< f "1" >}} is as short as it could be, compared to the considerably easier to type [^1]) makes for unnecessary complication.

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 <div class="footnotes" role="doc-endnotes"> and prefaces it with an <hr>. Providing the same HTML as Goldmark would allow there to be no disruption when the default render hook is added.

@cmpute
Copy link

cmpute commented Jan 16, 2023

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.

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.

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?

I will close this down for now, we need to revisit this problem later.

Is there any further discussion on this? Maybe it's time to revisit it now? @bep Thanks!

@cmpute
Copy link

cmpute commented Jan 16, 2023

If #5087 can be implemented, then it's not a problem anymore, but that issue seems no progress as well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants