You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a code block that uses the HTML <pre><code> tags contains HTML formatting such as <b> or <s>, and the block is highlighted using highlight.js, any such formatting is overridden. Such formatting should be retained whenever possible, and in cases where it clashes with formatting applied by highlight.js (happens most commonly when highlighting Markdown), the type specified in the HTML tags should take precedence.
Sample Code or Instructions to Reproduce
The following code contains <i> and <strike><b> tags to make part of it italicized and another part struck out and bolded. This works when the HTML elements <pre><code> are used:
<pre><code>...
GROUP BY model.name, <i>attempt.type</i>, <strike><b>attempt.result</b></strike>
...</code></pre>
When the highlighting is performed, it incorrectly looks like:
...
GROUP BY model.name, attempt.type, attempt.result
...
(when seen through a black-and-white camera)
Expected behavior
The parts surrounded by the <i> tag and the<strike><b> tags should be italicized, and bold and struck out respectively. This is how the code block looks like when not highlighted:
...
GROUP BY model.name, attempt.type, attempt.result
...
Additional context
This issue was discovered on Stack Exchange. This is the Meta Stack Exchange bug report; the above code samples came from there. I should also note that this behavior works properly in the previous highlighter Stack Exchange formerly used, Prettify.
The text was updated successfully, but these errors were encountered:
We call this kind of thing "HTML merging". This is intentionally no longer supported (in core) as in our opinion 98% of the time this is done inadvertently and only leaves users open to HTML injection attacks. This type of functionality can easily be added via plug-in for users who understand what they are doing:
Describe the issue/behavior that seems buggy
When a code block that uses the HTML
<pre><code>
tags contains HTML formatting such as<b>
or<s>
, and the block is highlighted using highlight.js, any such formatting is overridden. Such formatting should be retained whenever possible, and in cases where it clashes with formatting applied by highlight.js (happens most commonly when highlighting Markdown), the type specified in the HTML tags should take precedence.Sample Code or Instructions to Reproduce
The following code contains
<i>
and<strike><b>
tags to make part of it italicized and another part struck out and bolded. This works when the HTML elements<pre><code>
are used:When the highlighting is performed, it incorrectly looks like:
(when seen through a black-and-white camera)
Expected behavior
The parts surrounded by the
<i>
tag and the<strike><b>
tags should be italicized, and bold and struck out respectively. This is how the code block looks like when not highlighted:Additional context
This issue was discovered on Stack Exchange. This is the Meta Stack Exchange bug report; the above code samples came from there. I should also note that this behavior works properly in the previous highlighter Stack Exchange formerly used, Prettify.
The text was updated successfully, but these errors were encountered: