maud icon indicating copy to clipboard operation
maud copied to clipboard

empty tags using semicolons should create closing tags for non-void elements

Open twynb opened this issue 1 year ago • 0 comments

Take this example code:

html! {
    footer {
        div class="nav-padding";
        div class="nav-item" { "example1" }
        div class="nav-item" { "example2" }
        div class="nav-item" { "example3" }
        div class="nav-padding";
    }
}

I'd expect the divs closed by semicolons to become empty divs:

<footer>
    <div class="nav-padding"></div>
    <div class="nav-item">example1</div>
    <div class="nav-item">example2</div>
    <div class="nav-item">example3</div>
    <div class="nav-padding"></div>
</footer>

The actual output is (with whitespace added for readability):

<footer>
    <div class="nav-padding">
        <div class="nav-item">example1</div>
        <div class="nav-item">example2</div>
        <div class="nav-item">example3</div>
        <div class="nav-padding">
</footer>

This matches the behaviour documented in Elements and attributes, only creating an opening tag (because that works for <br> tags), but is a needless pitfall.

My suggestion would be to either insert a closing tag for tags that need one (like <div>) or to have this throw an error within the macro - since you can't manually close a div tag opened using div;, this always leads to invalid/broken HTML.

twynb avatar Jul 01 '24 08:07 twynb