2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-27 19:16:44 +00:00

Add docs for rendering markdown content (#9364)

This commit is contained in:
Oliver 2025-03-24 10:59:45 +11:00 committed by GitHub
parent fe807cb826
commit fc5b8479cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 %}
<h3>Part Notes</h3>
<p>
{{ part.notes | markdownify }}
</p>
{% 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.