I’ve come up with a way to do sticky headings in pure CSS. In order to create a theme with this technique, I need some control over how Zola renders page.content.
I don’t think the templating engine would make this possible.
I went to make a pull request, but the message on github indicated that I should discuss it here first. To prove to myself that it could be done, I put together an implementation on my own fork:
I thought about how this could be made more generic – maybe some people would want to use a tag other than <section>.
I think the ideal would have been to be able to bundle some code for post-processing as part of the theme (so that the needs of each theme don’t have to spill into the main rendering code), but for now that doesn’t seem as feasible.
That’s extremely unlikely to be merged as it’s essentially creating a custom output of CommonMark (never seen before afaik?) for one very very specific use-case.
I think semantically it makes sense to group everything under a specific heading in a <section>, so it’s not entirely without reason. Could you clarify what you mean by “custom output of CommonMark”? I see that the spec uses HTML as an example, but I didn’t think that meant there was only one way to convert from CM to HTML.
More generally, would you say that having control over rendering (i.e. page.content) is out-of-scope for Zola? What I’m really hoping for is a way to give themes more flexibility by letting them influence the rendering process.
Output matching the spec only matters if they user hadn’t, in their understanding of the situation, specified otherwise. It would be meaningful to enable users to parse their input differently – say, by automatically invoking semantic HTML rules – as long as the input + spec = output paradigm is set as default and other options are not enforced without user’s say-so.
My concern is not with having a heading ID – that much I’ve already read about in the manual – or having a specific element in output. My concern is being able to automatically produce semantic HTML without having to manually drive the process at any stage, beyond setting the variable.
Creating <section> tags automatically from headings levels in markdown does seem like a valid request to me. There have also been suggestions on how to specify HTML5 semantic sections through an extension to Markdown, but that is obviously not part of CommonMark: https://blogs.pjjk.net/phil/html5-semantic-sections-with-markdown/
I also find myself needing this to make my CSS work. I’m disappointed that the majority opinion seems to be that this is out of scope, but I don’t understand why you’d say it’s outright invalid. If I understand correctly, you’re saying that the HTML output must match CommonMark exactly in all configurations, regardless of what such a deviation would enable. That is a truly odd position.