Skip to content

Emphasis erroneously combined with parent element #288

@claviska

Description

@claviska

If drop-font-tags is true, any inline element containing b, u, i, or strike will inherit the respective style attribute(s) and the emphasis element(s) will be dropped.

Example input:

<i>Test</i>

<div>
    <i>Test</i>
</div>

<a href="#">
    <i>Test</i>
</a>

<span>
    <i>Test</i>
</span>

Example output (linebreaks added for clarity):

<i>Test</i>

<div>
    <i>Test</i>
</div>

<a href="#" style="font-style: italic">Test</a>

<span style="font-style: italic">Test</span>

The only flag I can find to affect this behavior is drop-font-tags, which I discovered by process of elimination. According to the docs:

This option specifies if Tidy should discard <FONT> and <CENTER> tags without creating the corresponding style rules. This option can be set independently of the clean option.

That plus the inconsistent behavior demonstrated above leads me to believe this is a bug.

Note: While this wouldn't normally affect the visual representation of the markup, it does alter the structure. A large number of websites and apps use icon libraries with a syntax such as <i class="fa fa-pencil"></i>, and this behavior breaks them in the cases above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions