I'm using django-pygmentify package in order to highlight my code blocks in my Django templates. The thing is that this package only supports code blocks as input. I have a model field that keeps markdown data. This markdown content might contain code blocks. (using ``` symbol)
Now, how can I highlight its inner code blocks??
Imagine I have a field that only contains source code. Like:
print('Hey..!')
In that case, this one works properly.
{% load pygmentify_tags %}
...
{% pygmentify %}
{{post.code}}
{% endpygmentify %}
Imagine my field contains the following content.
## Hello
This is my first step working with Python.
```python
print('Hey..!')
```
In this case, how can I implement it?? I can render that whole markdown content with {{post.body|markdown|safe}}
, but how can I highlight those code blocks?? I also want to give all those code blocks a class name .code-block
for better styling. Should I create a custom template tag?