Hugo

Table of contents for MMark?

I added some MMark pages to a site that I’m building but the table of contents (adding using the standard {{ .TableOfContents }} method, seems to yield nothing. Changing the file type back to standard .md then successfully displays the TOC. As far as I can tell, there are no other factors that could account for this.

Has anyone else successfully used TOCs with MMark? Anything that I’m missing? I may file an issue on the MMark repo and add an addendum to the Hugo docs in the MMark “caveats” section if I can’t get over the hump with this.

Okay, looks like this is a known issue: https://github.com/gohugoio/hugo/issues/3719. Alas. I’ll have a look and see what kind of work it would take to fix and file a PR if possible.

https://github.com/miekg/mmark/issues/113

Yeah, I saw this. This seems to be a separate issue from the Hugo TOC but I’ll reach out to the MMark creator and see if I can get some traction on this issue.

It is directly connecting with TOC not working with Mmark in Hugo. We have been updating MMark without realizing that the TOC support vanished (no specific test for that, I guess). I haven’t followed the Blackfriday v2 development, but I have raised an issue to get some kind of “content hook” so we could, say, create a table of content etc. data structure that we could feed to the templates. If both MMark and BF had a uniform way of exposing that, it would be a dream …

A note added to the above: Blackfriday v2 (close to getting ready) has a Parse method that returns a “syntax tree” ready for render; and I guess TOC etc. can be extracted from that.

Excellent! I will definitely be tracking developments on this and I’ll see if I can be of help. Appreciate it very much.

It seems that as of hugo 0.53, posts generated from mmark files or pdc files(pandoc file type) are still not showing table of contents. Any solutions or hints?

I’m afraid not. The .TableOfContents variable simply isn’t supported for those doc types.