threedaymonk / htmlbeautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
MIT License
325 stars 59 forks source link

Allow general self-closing tags #39

Closed Wonicon closed 7 years ago

Wonicon commented 7 years ago

In some cases, we might have html code embedded with svg code like:

<html>
  <body>
    <svg>
      <path fill="..." />
      <path fill="..." />
    </svg>
  </body>
</html>

As the tag belongs to svg specification, it will not be recognized as standalone_element but open_element, causing the following html tags to indent incorrectly.

Ending with /> can guarantee that the tag is a self-closing tag. Therefore I think we can recognize these tags as standalone_element regardless of their names.

threedaymonk commented 7 years ago

This seems useful, but can you add some tests, please?

nathanmarks commented 7 years ago

@threedaymonk can this get merged+released? anything still needed?

threedaymonk commented 7 years ago

I'm really sorry! I didn't see that you'd added the tests.

threedaymonk commented 7 years ago

Merged into master. Thank you!

threedaymonk commented 7 years ago

And released in version 1.2.1.