From 09429bb01f6b0112b2a7a6b10bdc35e079da97fa Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Sat, 19 Feb 2022 12:57:36 +0100 Subject: Book: document markdown filter --- book/src/filters.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'book/src') diff --git a/book/src/filters.md b/book/src/filters.md index 9fb71c5..f8e30a7 100644 --- a/book/src/filters.md +++ b/book/src/filters.md @@ -38,6 +38,7 @@ but are disabled by default. Enable them with Cargo features (see below for more * **[Optional / feature gated filters][#optional-filters]:** [`json|tojson`][#json], + [`markdown`][#markdown], [`yaml`][#yaml] * **[Custom filters][#custom-filters]** @@ -369,6 +370,30 @@ Ugly: Ugly: ``` +### `markdown` +[#markdown]: #markdown + +Enabling the `markdown` feature will enable the use of the `markdown` filter. +This will render a value using a [GitHub flavored CommonMark](https://docs.rs/comrak/0.12.*/comrak/) syntax. +By default the extensions “autolink”, “strikethrough”, “tagfilter”, and “table” are enabled. +Any raw HTML gets escaped. + +```jinja +{{ "**Hello, world!**"|markdown }} +``` + +Output: + +```html +

<i>Hello</i>, world!

+``` + +You can change the default settings by supplying [custom options][ComrakRenderOptions], e.g. to enable unsafe raw HTML. +You can find a usage example in our [unit tests][markdown-tests]. + +[ComrakRenderOptions]: https://docs.rs/comrak/0.12.*/comrak/struct.ComrakRenderOptions.html +[markdown-tests]: https://github.com/djc/askama/blob/5748c357d435b24848d1571df010d777859fede9/testing/tests/markdown.rs#L36-L75 + ### `yaml` [#yaml]: #yaml -- cgit