rareyman/HTMLBeautify

<select> bug

Closed this issue · 1 comments

I found an error in the plugin.

Formatting when there is a is not done correctly.

See with input:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Select Tag Bug</title>
    </head>
    <body>
        <div>
            <label>Text</label>
            <input type="text" />
        </div>
        <div>
            <label>Text</label>
            <input type="text" />
        </div>
        <div>
            <label>Text</label>
            <input type="text" />
        </div>
        <div>
            <label>Text</label>
            <input type="text" />
        </div>
        <div>
            <label>Text</label>
            <input type="text" />
        </div>
    </body>
</html>

vs select

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Select Tag Bug</title>
    </head>
    <body>
        <div>
            <label>Text</label>
        <select></select>
    </div>
    <div>
        <label>Text</label>
    <select></select>
</div>
<div>
    <label>Text</label>
<select></select>
</div>
<div>
<label>Text</label>
<select></select>
</div>
<div>
<label>Text</label>
<select></select>
</div>
</body>
</html>

the select correct is:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Select Tag Bug</title>
    </head>
    <body>
        <div>
            <label>Text</label>
            <select></select>
        </div>
        <div>
            <label>Text</label>
            <select></select>
        </div>
        <div>
            <label>Text</label>
            <select></select>
        </div>
        <div>
            <label>Text</label>
            <select></select>
        </div>
        <div>
            <label>Text</label>
            <select></select>
        </div>
    </body>
</html>

Whenever a <select> tag appears, he steps back a tab...

This is a plugin error?

I'm using the sublime text 3.

Thanks.

Hi there!

Well, the <select> tag usually has contents inside of it and is not usually displayed as a one line tag. The script is looking for a </select> line to unindent, so this is why the script is a bit confused.

A work around is to break the <select></select> into two separate lines—or you could add <select.*</select> as a tag_pos_inline option:

// these tags can sometimes be on one line (see example below) "tag_pos_inline": "<area.*>|<link.*/>|<link.*\">|<link.*>|<meta.*/>|<script.*</script>|<div.*</div>|<a.*</a>|<li.*</li>|<dt.*</dt>|<dd.*</dd>|<th.*</th>|<td.*</td>|<legend.*</legend>|<label.*</label>|<option.*</option>|<input.*/>|<input.*\">|<span.*</span>|<p.*</p>|<path.*/>|<!--.*—>|<select.*</select>",

I hope that helps!