pypi djlint 1.43.0

5 hours ago

Feature

  • New --stdin-filename option gives content piped in on stdin (djlint -) its real path, so per-file-ignores matches against that name and linter messages report it. Per-file ignores were previously dead for piped input, since nothing matches the name -. Path separators are normalized as they are for files on disk.

Fix

  • An apostrophe inside a template tag nested in an attribute value (title="{% translate "You don't have permission" %}") no longer swallows the rest of the document, which made H025 report every enclosing element as an orphan. A template tag in a value is now skipped whole unless it holds a >, so a quoted literal like a="{{" is still left alone.
  • A line that starts with a closing tag and ends with a whole tag (</span>tail<textarea>y</textarea>) unindents again; everything after it stayed one level too deep.
  • A template block tag followed by a whole html tag on the same line ({% endif %} <td class="x">y</td>) indents as a block tag again, so {% endif %} unindents and {% else %} aligns with its {% if %}. A line only takes that shape once the tag fits on one line, so reformatting an already formatted file moved it.
  • A tag opened after the end of a verbatim block on the same line (</pre> <span>x) is tracked again; its closing tag took a level from a tag opened before the block, dedenting that tag's siblings.
  • A template control block written across lines is kept that way when it opens against a tag (<div>{% if x %}), and the choice is no longer applied to the wrong block. Blocks were paired with the source by position, which does not line up with the expanded html; they are now matched by tag and contents.
  • A tag whose style, srcset, data-srcset or sizes value was written over several lines is no longer spread over multiple lines and pulled back together on the next run. max_attribute_length is now measured against what is written out, not against padding that the rewrite drops.
  • A <pre> or <textarea> opened on a line that also holds a self-contained comment (<pre>x<!--c-->) is recognized as opening a verbatim block again. Its contents were re-indented instead of left alone, and the closing </pre> gained an indent level on every run - unbounded whitespace growth inside preformatted text.
  • A closing tag that starts its line no longer dedents when the tag it closes was opened after text on an earlier line (text <b>bold / </b> tail). The loss accumulated, so a document repeating that shape drifted further left with each occurrence. A closing tag with nothing to pair against still dedents as before.
  • A < inside a one-line <script>, <style>, <textarea> or <title> no longer counts as a tag when indenting. <script>var a = '<span>'</script> left a phantom open <span> on the tag stack, leaving everything after it one level too deep.
  • An inline element that opens after text on its line and closes on a later line no longer dedents everything that follows it by one level (text <b>bold / more</b> tail inside a <p>) - a regression in 1.40.8. The wrong output was idempotent, so it survived later runs.
  • A Go template comment {{/* ... */}} is no longer read as a block close tag. It starts with {{/, the handlebars block-close prefix, so it popped a block off the stack: H037 reported Duplicate attribute found. for mutually exclusive attributes such as <a {{if .A}}href="a"{{else}}{{/* c */}}href="b"{{end}}>, and the formatter unindented the rest of the block. A comment renders as nothing, so H037 no longer treats one as a template-generated attribute name prefix either.
  • A tag that merely touches an ignored block is no longer treated as being inside it. A tag ending exactly where an ignored block starts - such as {% if x %}{# comment #} - was skipped by the linter, most visibly making T038 report End tag has no matching block tag for a balanced {% if %}. Affects every rule that skips ignored blocks (H025, H037, H041, H042, T002, T003, T027, T038, T039) and every kind of ignored block.
  • A bare djlint:off pragma no longer ignores the tag written immediately before it. <img>{# djlint:off #} silently dropped every error on that <img>, while <img>{# djlint:off H013 #} correctly reported it - a pragma covers what follows it, not what precedes it.

Don't miss a new djlint release

NewReleases is sending notifications on new releases.