Closed 64 closed 5 years ago
I think that's pretty unlikely to be added in Tera itself as it can be added to whatever app you have in 5 minutes https://github.com/getzola/zola/blob/master/components/templates/src/filters.rs#L7-L31
Fair enough. I don't mind if you close this issue.
For those visiting from the future: Zola's Markdown logic (as linked to there) is much more complex now as it interfaces with Tera.
If you're just looking for basic Markdown rendering and don't need anything more complex, you can do this:
[dependencies]
markdown = "1.0.0-alpha.14" # or 1.0, if released when you're reading this
tera.register_filter(
"markdown",
|value: &tera::Value, _: &_| -> tera::Result<tera::Value> {
let value = tera::from_value::<String>(value.clone())?;
let value = markdown::to_html(&value);
Ok(tera::to_value(value)?)
},
);
{{ package.description | markdown }}
It would be great to have some kind of feature flag on this crate which enables support for markdown rendering. You'd do something like:
Then inside a template, you could do:
And it would render as:
You could use pulldown-cmark for this.