cobalt-org / cobalt.rs

Static site generator written in Rust
cobalt-org.github.io/
Apache License 2.0
1.34k stars 100 forks source link

Include Markdown in Liquid templates #342

Open jcgruenhage opened 6 years ago

jcgruenhage commented 6 years ago

It would be useful to be able to include markdown in a liquid template file. If you try that now, the raw markdown will be copied over instead of compiling it.

@epage had a cool idea over in the chatroom:

{markdown}
List
- a
- b
- c
{endmarkdown}

inside the liquid file would trigger the stuff in between to be compiled to html, which would mean that

<random>
{markdown}
{include file.md}
{endmarkdown}
</random>

should then also work.

epage commented 6 years ago

Use case

A little background on that: I'm currently trying to move to something built on cobalt (who would have guessed) and html5up.net/hyperspace. I prefer having the actual content in md instead of html, so I'm trying to replace all the demo content from there with includes to my markdown files, which doesn't work because of the issue above

The main problem is that its not like some html, then a block of content and then some more html, but a lot of formatting with divs, classes and stuff, with content in sections between that

epage commented 6 years ago

Workarounds that failed:

One idea is to parse an include as markdown based on its extension. My concerns with that

This is what then led to the idea of the {markdown} block.

matan-h commented 1 month ago

In jekyll its possbile to do that with markdown="block" attribute ( from Kramdown ):

The markdown attribute: If an HTML tag has an attribute markdown="0", then the tag is parsed as raw HTML block. If an HTML tag has an attribute markdown="1", then the default mechanism for parsing syntax in this tag is used. If an HTML tag has an attributemarkdown="block", then the content of the tag is parsed as block level elements. If an HTML tag has an attribute markdown="span", then the content of the tag is parsed as span level elements.

I wonder if someone has implemented it in Rust