diff options
author | René Kijewski <kijewski@library.vetmed.fu-berlin.de> | 2022-02-19 12:57:36 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-02-21 11:35:50 +0100 |
commit | 09429bb01f6b0112b2a7a6b10bdc35e079da97fa (patch) | |
tree | 687a493d4de1a3c850ddda873e44e43235bcdd9a /book/src | |
parent | 3efd753e5a15cf9003e9bd64bf9785e8d4e4d4b9 (diff) | |
download | askama-09429bb01f6b0112b2a7a6b10bdc35e079da97fa.tar.gz askama-09429bb01f6b0112b2a7a6b10bdc35e079da97fa.tar.bz2 askama-09429bb01f6b0112b2a7a6b10bdc35e079da97fa.zip |
Book: document markdown filter
Diffstat (limited to 'book/src')
-rw-r--r-- | book/src/filters.md | 25 |
1 files changed, 25 insertions, 0 deletions
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: <script>var data = "{{data|json}}";</script> Ugly: <script>var data = '{{data|json|safe}}';</script> ``` +### `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 +{{ "**<i>Hello</i>, world!**"|markdown }} +``` + +Output: + +```html +<p><strong><i>Hello</i>, world!</strong></p> +``` + +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 |