djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
664 stars 81 forks source link

[BUG] [Formatter] blank_line_after_tag should not add a new line if indent is decreased #827

Open lukepass opened 5 months ago

lukepass commented 5 months ago

System Info

Issue

When using the option blank_line_after_tag the formatter should not add a new blank line if the line directly after the tag is a closing tag with decreasing indent:

<!DOCTYPE html>
<html lang="it">
    <head>
        <meta charset="UTF-8">
        <title>
            {% block title %}My website{% endblock %} <!-- There should not be a new line after this -->

        </title>
        <link rel="icon" href="{{ asset("logo.ico") }}" type="image/x-icon">
        {# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
        {% block stylesheets %}{{ encore_entry_link_tags("app") }}{% endblock %} <!-- Here is OK -->

        {% block javascripts %}{{ encore_entry_script_tags("app") }}{% endblock %} <!-- There should not be a new line after this -->

    </head>
    <body>
        {{ include("shared/_header.html.twig") }}
        <div class="container mx-auto">
            {% block body %}{% endblock %} <!-- There should not be a new line after this -->

        </div>
    </body>
</html>

How To Reproduce

Set blank_line_after_tag to a tag and format the file.

Thanks!