djlint / djLint

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

[BUG] [Formatter] Formatting breaks on "/>" in HTML attributes #792

Open zyzzyxdonta opened 10 months ago

zyzzyxdonta commented 10 months ago

System Info

Issue

HTML attributes containing the string /> cause unindent in the following lines. This case comes up, e.g. when using hyperscript CSS query selectors.

How To Reproduce

example.html.txt

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="description" content="An example" />
    <meta name="keywords" content="test" />
    <title>Test</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
          rel="stylesheet">
    <script src="https://unpkg.com/hyperscript.org@0.9.12"></script>
  </head>
  <body class="container">
    <div class="row mt-3">
      <div class="col">
        <button id="button-1"
                type="button"
                class="btn btn-primary"
                _="on click toggle .d-none on <#button-2, #button-6/>">Button 1</button>
        <button id="button-2" type="button" class="btn btn-success">Button 2</button>
        <button id="button-3" type="button" class="btn btn-danger">Button 3</button>
      </div>
    </div>
    <div class="row mt-3">
      <div class="col">
        <button id="button-4" type="button" class="btn btn-primary">Button 4</button>
        <button id="button-5" type="button" class="btn btn-success">Button 5</button>
        <button id="button-6" type="button" class="btn btn-danger">Button 6</button>
      </div>
    </div>
  </body>
</html>
welcome[bot] commented 10 months ago

Thanks for opening your first issue here!