Strange behaviour of <code> blocks with syntax highlighting

Created on 23 February 2024, 10 months ago
Updated 29 April 2024, 8 months ago
# code block without class should suffer from double escaping, PHP syntax highlighting via class="language-php" will be added by default

&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;

# It gets wrapped in another pre tag when saving.
# When switching to rich text editor, the surrounding <pre> tag is removed and moved above the current tag as empty <pre></pre> tag.
# code block without wrapping <pre> (not escaped) is correctly wrapped in a single <pre> tag
# and without class should suffer from double escaping, PHP syntax highlighting via class="language-php" will be added by default

&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;
code block with "language-" class should prevent double escaping and prevent PHP syntax highlighting
<p>paragraph</p>
<?php echo $test; ?>
# code block with "language-php" class should prevent double escaping and should use PHP syntax highlighting
<p>paragraph</p>
<?php echo $test; ?>
<!-- code block with "language-html" class should prevent double escaping and should use HTML syntax highlighting -->
<p>paragraph</p>
<?php echo $test; ?>

Original markup in plain text editor:

<pre><code>
# code block without class should suffer from double escaping, PHP syntax highlighting via class="language-php" will be added by default

&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;

# It gets wrapped in another pre tag when saving.
# When switching to rich text editor, the surrounding <pre> tag is removed and moved above the current tag as empty <pre></pre> tag.
</code></pre>

<code>
# code block without wrapping <pre> (not escaped) is correctly wrapped in a single <pre> tag
# and without class should suffer from double escaping, PHP syntax highlighting via class="language-php" will be added by default

&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;
</code>

<pre><code class="language-">
code block with "language-" class should prevent double escaping and prevent PHP syntax highlighting
&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;
</code></pre>

<pre><code class="language-php">
# code block with "language-php" class should prevent double escaping and should use PHP syntax highlighting
&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;
</code></pre>

<pre><code class="language-html">
&lt;!-- code block with "language-html" class should prevent double escaping and should use HTML syntax highlighting --&gt;
&lt;p&gt;paragraph&lt;/p&gt;
&lt;?php echo $test; ?&gt;
</code></pre>
🐛 Bug report
Status

Closed: outdated

Version

0.0

Component

Miscellaneous

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024