Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with Gutenberg 17.1 after it removed preserveWhiteSpace serialisation differences #791

Merged
merged 3 commits into from
Jan 20, 2024

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)

@westonruter westonruter merged commit dc0111c into develop Jan 20, 2024
2 checks passed
@westonruter westonruter deleted the fix/pre-br branch January 20, 2024 00:55
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
1 participant