beautifier / js-beautify

Beautifier for javascript
https://beautifier.io
MIT License
8.61k stars 1.39k forks source link

Handlebars {{#tr}} helper is indented as if it were a <tr> tag #2045

Open andersk opened 2 years ago

andersk commented 2 years ago

Description

Zulip defines a custom Handlebars helper {{#tr}} for translation, but when it happens to be used inside a table cell, js-beautify seemingly confuses it with a <tr> (table row) tag and indents it at the wrong level.

Input

The code looked like this before beautification:

<table>
    <tr>
        <td>
            {{#tr}}translated{{/tr}}
        </td>
    </tr>
</table>

Expected Output

The code should have looked like this after beautification:

<table>
    <tr>
        <td>
            {{#tr}}translated{{/tr}}
        </td>
    </tr>
</table>

Actual Output

The code actually looked like this after beautification:

<table>
    <tr>
        <td>
    {{#tr}}translated{{/tr}}
    </td>
    </tr>
</table>

Steps to Reproduce

html-beautify -H test.hbs

Environment

OS: Linux

Settings

None

bitwiseman commented 2 years ago

I've marked this as a good first issue, though it is a bit more involved. Basically, we currently have a single stack for all tags, both html and handlebars. We need to add a separate stack for handlebars.

eltonls commented 2 years ago

Can you assign me to that issue?

bitwiseman commented 1 year ago

@eltonls You are welcome to work on this. There are few enough contributors that assign issues is not useful.

Meesujit commented 1 year ago

if this issue is open can you assign it to me.

bitwiseman commented 1 year ago

@Meesujit
We do not assign issues. There are few enough contributors that assign issues is not useful. Also, people ask for assignment and then never work on the issue. Please feel free to work on this and submit a PR.