Inclusion of third-party Goldmark Extensions?

Goldmark includes a system for extensions, but the author is (understandably!) conservative about what is included in the main repository. This came up when I submitted a PR to enable labeled footnotes ([^name] instead of just [^1]), and only then realized that the goal of Goldmark’s footnote support was to mirror PHP Markdown Extra’s footnote feature, not BlackFriday’s.

Such a feature would be easy to craft as an extension, but it would have to be enabled at compile time and built into the Hugo executable, I believe. (If that is not the case, please let me know!)

I totally understand if we wouldn’t want to introduce another external dependency to Hugo just for the sake of this relatively minor point of feature parity with a deprecated library, but is there any interest in a feature like this? I’d be happy to create the Goldmark extension, but the author was clear that it wasn’t something that would be accepted in the main repository.

Would we perhaps be open to having a set of Goldmark extensions that are part of Hugo? It might be overkill or invite too much bikeshedding, but it feels like a useful question to ask going forward if Goldmark is going to be the default renderer; eventually I imagine there might be other Markdown rendering features that would benefit Hugo.

(Background: I rely on the unique anchor tags generated by labeling footnotes this way (when assembling several pages into a larger one) so for now I’m sticking with BlackFriday as my Markdown renderer, but I’d like to be ready for a future where that’s no longer an option.)

4 Likes

Any answer/update on the above? :slightly_smiling_face:

I’m skipping the general question here, but how do GitHub treat footnotes?

For the record, I can’t answer your question, I was wondering about Goldmark &updated this thread because I’m trying to assess how to tackle my own footnote “issue”/wish. :slightly_smiling_face:

GitHub Flavored Markdown does not support footnotes at all, if that’s what you’re asking.

Meanwhile, GitHub has been supporting footnotes in Markdown for about 2 years now. User documentation is found here (but doesn’t give any insight into the implementation).

The current GFM spec has not been updated since 2019-04-06 and hence doesn’t mention anything about footnotes.

What I observed so far:

  • On GitHub, a footnote with identifier my_foot is rendered to HTML elements with the two ids

    • user-content-fnref-my_foot-HASH and
    • user-content-fn-my_foot-HASH

    where HASH is some 32-character hash value.

  • On GitLab, a footnote with identifier my_foot is rendered to HTML elements with the two ids

    • fnref-my_foot-####
    • fn-my_foot-####

    where #### is some 4-digit number.

The list of (officially acknowledged) third-party goldmark extensions seems to constantly grow, there are now also ones for katex and mermaid.

In conjunction with Hugo they would allow static pages without any JS dependencies to support mermaid and katex code blocks in Markdown content authoring (rendered to SVG by Goldmark/Hugo).

I suspect such features would be of interest for a lot of Hugo users and theme developers.

Any chance the officially acknowledged third-party goldmark extensions could be integrated in Hugo’s extended version and the markdown code block parsing of the respective format additions be made opt-in via global config? And perhaps, possibly existing codeblock render hooks could even have precedence over goldmark-rendering for maximum flexibility?

I also wonder whether Hugo’s GoAT support wouldn’t be better served as a Goldmark extension. :thinking:

Just to narrow the conversation a bit…

The first three are maintained by the Goldmark project lead.

Extension Maintainer Last update Stars Notes
goldmark-emoji yuin 2023-07-02 16 we’re using it
goldmark-highlighting yuin 2023-07-29 82 irrelevant
goldmark-meta yuin 2022-02-17 60 irrelevant
goldmark-anchor abhinav 2023-10-15 2 use render hook or js
goldmark-d2 FurqanSoftware 2023-07-20 14 renders to SVG :+1:
goldmark-embed 13rac1 2020-12-20 2 use render hook
goldmark-fences stefanfritsch 2023-01-16 3 this is a pandoc thing[1]
goldmark-figure mangoumbrella 2023-04-26 3 use render hook
goldmark-frontmatter abhinav 2023-10-15 5 irrelevant
goldmark-hashtag abhinav 2023-10-15 5
goldmark-img64 tenkoh 2023-03-12 0 use render hook
goldmark-katex FurqanSoftware 2023-08-19 4 renders to MathML :+1:
goldmark-latex soypat 2023-06-17 10 irrelevant
goldmark-mathjax litao91 2021-02-16 40 requires stylesheet
goldmark-mermaid abhinav 2023-10-23 28 has external dependency[2]
goldmark-pdf stephenafamo 2023-01-06 105
goldmark-pikchr jchenry 2023-07-18 2 wraps pikchr.c :-1:
goldmark-toc abhinav 2023-10-15 9 irrelevant
goldmark-wikilink abhinav 2023-10-15 17

  1. Set markup = 'pandoc' in front matter, or change file extension to .pdc ↩︎

  2. With server-side rendering, goldmark-mermaid calls out to the MermaidJS CLI to render SVGs inline into the document. ↩︎

3 Likes

goldmark-fences would bring Pandoc’s fenced_divs to the Hugo world which would also be a big win.

@jmooring The fact that goldmark-mermaid calls out to the MermaidJS CLI isn’t an inherent blocker for inclusion in Hugo, right? It just means users would have to npm i @mermaid-js/mermaid-cli to be able to use the feature, no?

1 Like

No, it means we’d need to wire Hugo to talk to the CLI, similar to the PostCSS implementation.

So I’m doing a lot of table stuff, and I was wondering how difficult it would be to enable the goldmark-wiki-tables extension?