DjHTML 3 is here!
This major new release fixes all outstanding bugs in DjHTML π₯³
There are no backwards-incompatible changes in the usage of DjHTML, but the indentation it produces has been improved significantly. Here is an overview of all the things that changed:
Support for Python 3.6 and 3.7 has been dropped
Sorry folks, but these Python versions are now so old it's time to drop support. If you're forced by whatever reason to use Python 3.6 or 3.7, please use DjHTML version 2 or older because they still work fine (minus all the improvements this release brings, of course).
New multiline HTML element indentation
The long-standing issue #50 has finally been solved! DjHTML not only carefully aligns the attributes of multi-line HTML elements, it even aligns the contents of multi-line attribute values! The README now starts with this very appropriate example:
<blockquote cite="Guido Van Rossum"
style="font-style: italic;
{% if dark_mode %}
background: black;
{% endif %}
">
Don't you hate code that's not properly indented?
</blockquote>
Thanks again @adamchainz for reporting this issue, and also for your other contributions π
Both opening and closing comment tags are now ignored
Previous versions of DjHTML indented the opening tag, but not the closing tag of comments, which resulted in ugliness like this:
<div>
<p>
{# ββββββββββββββββββββββββββββ
β Carefully laid out table β
ββββββββββββββββββββββββββββ #}
</p>
</div>
Now, DjHTML completely leaves comments alone.
Improved CSS and JS multi-line statements
Not just multi-line HTML elements have improved, also multi-line CSS statements (#74) and multi-line JS expressions (#59) have been improved thanks to new handling of relative and absolute offsets. There have been too many improvements to list here, but if you're curious about the indentation rules, check out the files in the test suite to see how they are indented.
Improved unittests
Speaking of the test suite, the unformatted *.in
files have been removed in favor of tracking new *.tokens
files that contain the exact internal representation of all available source files. This will help to identify bugs more easily and will guard against unintended changes to the way source is tokenized, even if those changes do not affect the indentation.
In addition to the unittests, DjHTML has been tested thoroughly by running it over many open source codebases such as Django, Sentry, Readthedocs, and of course the awesome Wagtail. This helped to identify a number of new bugs that have all been fixed as well.
Welcoming to contributors
One thing that hasn't changed is our openness to your contributions. We'd like to thank everyone for reporting bugs and suggesting improvements, and we'd like to encourage you to keep doing so. Without your help DjHTML wouldn't be as awesome as it is now!