Skip to content

[BUG] [Formatter] Unnecessary blank space #1245

@Hugo-Heagren

Description

@Hugo-Heagren

System Info

  • OS: e.g. debian bookworm
  • Python Version 3.11.2
  • djLint Version v1.36.4
  • template language: Jinja2

Issue

The formatter adds newlines/blank where I don't want it. I can see why this would make cleaner code, but in HTML it messes up the intended output. The docs don't describe a way of disabling this behaviour.

How To Reproduce

Take this.

<i>
({{ p.eventtitle }}{% if p.institution | first %}; <!-- this semicolo *has* to directly follow the rendered content -->
{{ p.institution | first }}{% endif %}) <!-- likewise, this bracket *has* to directly follow the end of the content
</i>

On the web, this looks like this:

(Title of Interesting Event; Name of Institution)

If we format, we get:

<i>
    ({{ p.eventtitle }}
    {% if p.institution | first %}
        ; <!-- semicolon now on its own line -->
        {{ p.institution | first }}
    {% endif %}
    ) <!-- bracket on its own line -->
</i>

which on the web gives us this:

(Title of Interesting Event ; Name of Institution )

Notice the spaces before the semicolon and final bracket, which are added by the formatter.

I don't want this to happen. It might be a bug, or there might be an undocumented way to turn it off? Any help appreciated!

Hugo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions