Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Formatter] formatting not disabled inside <!-- djlint:off --> #769

Open
3 tasks done
ruanmed opened this issue Oct 4, 2023 · 3 comments
Open
3 tasks done
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@ruanmed
Copy link
Contributor

ruanmed commented Oct 4, 2023

System Info

  • OS: ubuntu 22.04
  • Python Version (python --version) 3.11.4
  • djLint Version (djlint --version) 1.34.0

Issue

In an HTML file (e.g.: file.html), djlint --reformat file.html ignores <!-- djlint:off --> tags and still reformats the content after the tag and before the <!-- djlint:on --> closing tag.

Issue is similar to #166

This behavior is inconsistent with documentation of djlint available on https://www.djlint.com/docs/ignoring-code/ for For plain old html - ignoring.

How To Reproduce

  1. Execute djlint --reformat file.html where file.html has the following contents:
<div>
<ul class="sub-menu collapse"
          id="functional">
<li>
    <a id="id1"
        href="#/id1"
        onclick="doSomething()">
    <i class="fa fa-search"
        aria-hidden="true"></i> Item 1
    </a>
</li>
<li>
    <a id="id2"
        href="#/id2"
        onclick="doSomething()">
    <i class="fas fa-search"></i> Item 2
    </a>
</li>
<li>
    <a id="id3"
        href="#/id3"
        onclick="doSomething()">
    <i class="fas fa-search"></i> Item 3
    </a>
</li>
<!-- djlint:off -->
<!-- HIDDEN -->
<!--<li>-->
<!--<a id="id4" href="#/id4" onclick="doSomething()">-->
<!--<i class="fa fa-search" aria-hidden="true"></i> Item 4-->
<!--</a>-->
<!--</li>-->
<!-- djlint:on -->
</ul>
</div>
  1. The file.html gets reformated to:
<div>
  <ul class="sub-menu collapse"
      id="functional">
    <li>
      <a id="id1"
         href="#/id1"
         onclick="doSomething()">
        <i class="fa fa-search"
           aria-hidden="true"></i> Item 1
      </a>
    </li>
    <li>
      <a id="id2"
         href="#/id2"
         onclick="doSomething()">
        <i class="fas fa-search"></i> Item 2
      </a>
    </li>
    <li>
      <a id="id3"
         href="#/id3"
         onclick="doSomething()">
        <i class="fas fa-search"></i> Item 3
      </a>
    </li>
    <!-- djlint:off -->
    <!-- HIDDEN -->
    <!--<li>-->
    <!--<a id="id4"
   href="#/id4"
   onclick="doSomething()">-->
    <!--<i class="fa fa-search" aria-hidden="true"></i> Item 4-->
    <!--</a>-->
    <!--</li>-->
    <!-- djlint:on -->
  </ul>
</div>

However, it should have been:

<div>
  <ul class="sub-menu collapse"
      id="functional">
    <li>
      <a id="id1"
         href="#/id1"
         onclick="doSomething()">
        <i class="fa fa-search"
           aria-hidden="true"></i> Item 1
      </a>
    </li>
    <li>
      <a id="id2"
         href="#/id2"
         onclick="doSomething()">
        <i class="fas fa-search"></i> Item 2
      </a>
    </li>
    <li>
      <a id="id3"
         href="#/id3"
         onclick="doSomething()">
        <i class="fas fa-search"></i> Item 3
      </a>
    </li>
<!-- djlint:off -->
<!-- HIDDEN -->
<!--<li>-->
<!--<a id="id4" href="#/id4" onclick="doSomething()">-->
<!--<i class="fa fa-search" aria-hidden="true"></i> Item 4-->
<!--</a>-->
<!--</li>-->
<!-- djlint:on -->
  </ul>
</div>
@ruanmed ruanmed added 🦠 bug Something isn't working 🧽 formatter labels Oct 4, 2023
@welcome
Copy link

welcome bot commented Oct 4, 2023

Thanks for opening your first issue here!

@baseplate-admin
Copy link

Same for this type of code

<div
   _ = "
   {# djlint:off #}
   js
        console.log(1)
   end
   {# djlint:on #}
    "
></div>

@myrgy
Copy link

myrgy commented Feb 18, 2024

Hello,

is there any updates on this?
Can I help to fix it?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

3 participants