From fc5b8479cbd90ff06f91e5f0b5aaf291d42b94ec Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 24 Mar 2025 10:59:45 +1100 Subject: [PATCH] Add docs for rendering markdown content (#9364) --- docs/docs/report/helpers.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/docs/report/helpers.md b/docs/docs/report/helpers.md index 7883637a2f..2220e886ce 100644 --- a/docs/docs/report/helpers.md +++ b/docs/docs/report/helpers.md @@ -86,8 +86,6 @@ A number of helper functions are available for accessing database objects: The `filter_queryset` function allows for arbitrary filtering of the provided querysert. It takes a queryset and a list of filter arguments, and returns a filtered queryset. - - ::: report.templatetags.report.filter_queryset options: show_docstring_description: false @@ -513,6 +511,26 @@ A [Part Parameter](../part/parameter.md) has the following available attributes: | Units | The *units* of the parameter (e.g. "km") | | Template | A reference to a [PartParameterTemplate](../part/parameter.md#parameter-templates) | +## Rendering Markdown + +Some data fields (such as the *Notes* field available on many internal database models) support [markdown formatting](https://en.wikipedia.org/wiki/Markdown). To render markdown content in a custom report, there are template filters made available through the [django-markdownify](https://github.com/erwinmatijsen/django-markdownify) library. This library provides functionality for converting markdown content to HTML representation, allowing it to be then rendered to PDF by the InvenTree report generation pipeline. + +To render markdown content in a report, consider the following simplified example: + +```html +{% raw %} + +{% load markdownify %} + +

Part Notes

+

+ {{ part.notes | markdownify }} +

+{% endraw %} +``` + +You can read further details in the [django-markdownify documentation](https://django-markdownify.readthedocs.io/en/latest/). + ## List of tags and filters The following tags and filters are available.