htacg/tidy-html5

'clean' moves style attributes

leonstr opened this issue · 0 comments

clean moves style attributes -- or with --show-body-only yes -- removes them. But the docs say clean will perform cleaning of some legacy presentational tags (currently <i>, <b>, <center> when enclosed within appropriate inline tags, and <font>). No mention of changes to style attributes.

For example with file test.hml:

<p style="color: green">Test</p>

and running tidy -q --show-body-only yes -clean /tmp/test.html I get:

<p class="c1">Test</p>

which has lost the style. I could use --show-body-only no but this isn't suitable when using the output in a program via libtidy.

And while CSS is tidier in a <style> element style attributes are allowed by the spec.

So, firstly: are the docs for clean wrong, or is the implementation wrong (or am I wrong)?
And secondly: would it be possible to retain style attributes for elements, for example, by making clean behave as currently documented. Or instead retain style attributes when clean and show-body-only are selected?