Stillat / blade-parser-typescript

A Laravel Blade parser, compiler, and static analyzer written in TypeScript.
https://stillat.com
MIT License
82 stars 2 forks source link

`body` closing tag not being terminated #111

Closed RobertBlaauwendraad closed 1 month ago

RobertBlaauwendraad commented 1 month ago
  <body @php(body_class())>
  <a class="action skip contentarea d-none" href="#contentarea">
    <span>{{ __('Ga naar de inhoud', 'suiteseven') }}</span>
  </a>
  @include('layouts.header' . (features()->get('woocommerce') && is_checkout() ? '-checkout' : ''))
...
  </body>

Gives:

SyntaxError: Opening tag "body" not terminated. (23:3)
[error]   21 |
[error]   22 |
[error] > 23 |   <body <BVP0Uzhv9ZgZRsgXgjB />>
[error]      |   ^^^^^^
[error]   24 |   <a class="action skip contentarea d-none" href="#contentarea">
[error]   25 |     <span>BfDxyyRND9Wn2T4AcFhDjbdfMS6ImHtGpylpaD9wpVAB</span>
[error]   26 |   </a>
[error]   21 |   <body @php(body_class())>
[error]   22 |   <a class="action skip contentarea d-none" href="#contentarea">
[error] > 23 |     <span>{{ __('Ga naar de inhoud', 'suiteseven') }}</span>
[error]      |   ^^^^^^
[error]   24 |   </a>
[error]   25 |   @include('layouts.header' . (features()->get('woocommerce') && is_checkout() ? '-checkout' : ''))
[error]   26 |

Wrapping <body @php(body_class())> and </body> with format-ignore resolves the problem

RobertBlaauwendraad commented 1 month ago

Also, the code inside the <body> tag doesn't get indented, which I think is nice However <html> does give indentation, maybe remove that as well?

JohnathonKoster commented 1 month ago

I cannot reproduce this with the provided template. This is usually caused by having unpaired elements (such as those inside conditions/etc.), which causes issues with prettier. I would also check to see if this is caused by something similar to this on your end:

https://github.com/Stillat/blade-parser-typescript/issues/109#issuecomment-2278090058

Feel free to re-open if that is not the case.

Also, the code inside the tag doesn't get indented, which I think is nice However does give indentation, maybe remove that as well?

IF the formatter encounters a catastrophic error, the original content will be returned. With valid input, code inside the <body> will get indented.