davidwessman / syntax_tree-erb

Syntax Tree support for ERB
MIT License
21 stars 3 forks source link

Support omitting self-closing tags of void elements like <meta> #95

Open matthew-puku opened 2 weeks ago

matthew-puku commented 2 weeks ago

Hey there,

This project is awesome!

Proposal

I wondered if it'd be worthwhile to make void elements not self-closing.

For example, <br>s might output as:

<p>
  so much depends<br>
  upon<br>
  <br>
  a red wheel<br>
  barrow<br>
  <br>
  glazed with rain<br>
  water<br>
  <br>
  beside the white<br>
  chickens.
</p>

Currently, the output looks like this:

<p>
  so much depends<br />
  upon<br />
  <br />
  a red wheel<br />
  barrow<br />
  <br />
  glazed with rain<br />
  water<br />
  <br />
  beside the white<br />
  chickens.
</p>

But why?

davidwessman commented 1 week ago

@rdimartino what do you think about this suggestion? Since you made some changes to the void-tags.

According to erb_lint they consider self-closing void elements to be XHTML style and writing them without self-closing as HTML5 style which I think is what modern browsers are targeting.

rdimartino commented 1 week ago

@davidwessman I think that I used self-closing tags in #73 to match how prettier formats HTML in my project, but I have come to believe that they're doing it wrong. I think this plugin should still be able to parse self-closing tags, but I support formatting the void elements as suggested here.