Problems generating complex Markdown in shortcodes

Hi! I’m trying to port my blog to Zola (for fun), and I think I have run into some edge cases. One of them is that I’d like to render some data from a file as markdown. Using my previous Jekyll setup, I used inline templating in the Markdown file, but AFAIK that is not possible in Zola.

So, I’m trying to write a shortcode template that renders to the correct Markdown. Sadly, it strips newlines (here I think), so paragraphs in Markdown just down work. My next try was to generate HTML, but then there is not table of contents…

Is there an option to not strip empty lines in shortcodes? Or some other way to accomplish this?

Since I can’t add so many links per post: Here’s the code to reproduce. This commit is the Markdown trial and this one is using HTML.

What exactly is the issue? The page http://127.0.0.1:1111/blog/several-months-of-reading-material/ is rendering fine locally and I do get paragraphs?

Thanks for having a look!

That’s the version where I just emit HTML from the shortcode, and don’t get a TOC. What I’d like to do instead is emit Markdown that is then processed like any other content. Checkout the other commit I linked to see how my attempt at that looks :slight_smile:

Ah I see what you mean. I’ll have a look this weekend.

Awesome! I’m also willing to dig into this as well if you let me know how :slight_smile:

Probably just try the markdown rendering shortcode and see what happens in https://github.com/getzola/zola/blob/47bd7c9e8250e227237aa3600efd02511aa54611/components/rendering/src/markdown.rs

The newline stripping is really needed afaik, but maybe there is a better way to handle it?

I see the issue but I’m not sure how to fix yet. Removing https://github.com/getzola/zola/blob/47bd7c9e8250e227237aa3600efd02511aa54611/components/rendering/src/shortcode.rs#L126 fixes it but it is needed to avoid https://github.com/getzola/zola/blob/master/components/rendering/tests/markdown.rs#L773

Maybe instead of trimming newline we could trim_start line by line to avoid the indentation issue?