djLint
djLint copied to clipboard
[BUG] [Formatter] Malformed formatted html containing jinja2 blocks and comments
- [x] I'm on the latest version of djLint
- [x] I've searched the issues
- [x] I've read the docs
System Info
- OS: Debian 11 & Manjaro
- Python Version:
python 10&python 11 - djLint Version:
1.19.15 - template language: jinja2
Issue
I am working with jinja templates and the formatter seems to be having some issues with these templates. Some tags are not aligned, jinja comments are ignored.
How To Reproduce
I am running the command djlint template.html --reformat --profile=jinja to reformat.
Input and Output
{% ckan_extends %}
{% block info_module %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="fa fa-info-circle"></i> {{ _('What are datasets?') }}
</h2>
<div class="module-content">
<p>
{# Modification start; original below #}
{#
{% trans %}
A CKAN Dataset is a collection of data resources (such as files),
together with a description and other information, at a fixed URL.
Datasets are what users see when searching for data.
{% endtrans %}
#}
{% trans %}
<p>Packages are the primary units of contents in the Eawag Research Data Platform.</p>
<p>
A package is a collection of
<ol>
<li>
<i><b>resources</b></i> (files or links) and
</li>
<li>
<i><b>metadata</b></i>, such as abstract, keywords, author, ...
</li>
</ol>
</p>
<p>Packages are what users find when searching for data.</p>
<p>Packages have a permanent URL.</p>
{% endtrans %}
{# Modification end #}
</p>
</div>
</section>
{% endblock %}
Desired
{% ckan_extends %}
{% block info_module %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="fa fa-info-circle"></i> {{ _('What are datasets?') }}
</h2>
<div class="module-content">
<p>
{# Modification start; original below #}
{#
{% trans %}
A CKAN Dataset is a collection of data resources (such as files),
together with a description and other information, at a fixed URL.
Datasets are what users see when searching for data.
{% endtrans %}
#}
{% trans %}
<p>Packages are the primary units of contents in the Eawag Research Data Platform.</p>
<p>
A package is a collection of
<ol>
<li>
<i><b>resources</b></i> (files or links) and
</li>
<li>
<i><b>metadata</b></i>, such as abstract, keywords, author, ...
</li>
</ol>
</p>
<p>Packages are what users find when searching for data.</p>
<p>Packages have a permanent URL.</p>
{% endtrans %}
{# Modification end #}
</p>
</div>
</section>
{% endblock %}
Possibly a dupe of #557. Comments are currently excluded from the formatter.