Skip to content

Conversation

@westonruter
Copy link
Owner

Fixes #790.

In Gutenberg 17.1, I paste the following into a new Code block:

<!DOCTYPE html>
<html>
    <head>
        <title>PHP Test</title>
    </head>
    <body>
        <?php echo '<p>Hello World</p>'; ?>
    </body>
</html>

When I look at the post_content, it shows the block markup as follows:

<!-- wp:code {"language":"xml"} -->
<pre class="wp-block-code"><code>&lt;!DOCTYPE html><br>&lt;html><br>    &lt;head><br>        &lt;title>PHP Test&lt;/title><br>    &lt;/head><br>    &lt;body><br>        &lt;?php echo '&lt;p>Hello World&lt;/p>'; ?><br>    &lt;/body><br>&lt;/html></code></pre>
<!-- /wp:code -->

This gets rendered as:

image

When this is what is expected:

image

This PR fixes the problem by ensuring BR tags are replaced with newlines before applying syntax highlighting.

@westonruter
Copy link
Owner Author

ZIP build: syntax-highlighting-code-block.zip (1.5.0-alpha-20231202T000854Z-3dc095a)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

br tags being added instead of line breaks

2 participants