Stillat / blade-parser-typescript

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

`{{ format-ignore-start }}` causes weird issues #44

Closed zepfietje closed 1 year ago

zepfietje commented 1 year ago

When ignoring a piece of Blade template and then running the formatter, I get the following error:

SyntaxError: Unexpected closing tag "div". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (172:9)
[error]   170 |             
[error]   171 | </Bvquium45fhI5Hw4B06nwmucmWxtkrsEmVaqZKZerQmrEcsaB>
[error] > 172 |         </div>
[error]       |         ^^^^^^
[error]   173 |     </BRx4jNgACUUiqJ9hvs1kvS7ZY6JX8daTucyyjUK5j0EZZv9fumHVUdQa19bj7p686KtcjVG7M4QUk0lkUk92T43W8H4soVgCw8TlLsbNPHmBtvDMDsUHRWVxGPAubvQzwjsts01bwrqiM6ibHJ5wKgL9j3jYGeSsDyot8zb1Ib0U01y12TlB>
[error]   174 |
[error]   175 | </div>

Edit: probably my fault as I added the comments around some attributes on a div, while it should wrap the entire div. However, when I wrap the entire div, its contents get replaced by <BoRWTjjG3HrujYEnB />.

JohnathonKoster commented 1 year ago

Would you be able to share more of the template that is causing the issue (note: there will be some situations where that error cannot be avoided, but will work to document those as they come up. A good example is starting/closing HTML tags or components inside conditions, etc.)? thanks!

zepfietje commented 1 year ago

Yeah it's inside a conditional. This is a minimal example which reproduces the issue:

@if (true)
    {{-- format-ignore-start --}}
    <div></div>
    {{-- format-ignore-end --}}
@endif
JohnathonKoster commented 1 year ago

Resolved in 1.3.0 for this situation 🙂

zepfietje commented 1 year ago

Great!