• Hey

    Just a heads up. Editing existing code snippets in WP 6.5 beta 3 or the current Gutenberg Plugin version, appears to replace newlines with br tags, and escape other html entities. Resulting in formatted code like this:

    … looking like this:

    Issue created on Github:
    https://github.com/WordPress/gutenberg/issues/59548

    I’m using Prism.JS for my code highlighting, but just verified that the same issue occurs with the Prismatic plugin.

    It’s important to note, that these changes to the content of your code block, are made when you edit the blocks. So just updating to WP 6.5 will not trigger the issue. You must edit and save a code block first.

    Is this something you can reproduce? I noticed you’ve tested with WP 6.5 beta. If so, please pitch in. It seems like this change is intentional.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Glad to help.

    I have not encountered this issue. But if you can provide the steps to repeat the error on default WordPress, I would be glad to investigate and try to resolve. Steps would look something along these lines:

    1. Install such and such
    2. Visit some page or area
    3. Perform some task
    4. Etc., until the issue occurs

    That way I can follow along, check it out, and try to help asap, thank you.

    • This reply was modified 8 months, 3 weeks ago by Jeff Starr.
    Thread Starter Bjarne Oldrup

    (@oldrup)

    Sure!

    Sorry for the missing screenshots. Limited to logged-in github users, apparently.

    There is a big thread here, with lots of screenshots etc.

    https://github.com/WordPress/gutenberg/issues/59548

    But to summarize:

    1. In WP 6.4; insert a code block with several lines of HTML
    2. Activate Prismatic (I’m was using PrismJS)
    3. Verify the code block is being rendered as expected (pre-formatted)
    4. Update to WP 6.5 beta
    5. Edit and re-save the code block
    6. Now the preformatted linebreaks, appears to be replaced with br tags, and the entire code snippet is rendered on a single line.

    Before; in WP 6.4

    After; in WP 6.5 beta 3

    Oh, and I’m using the standard WordPress code block. That was the nice thing about Prism.JS. No custom block needed. Just a class.

    WP seems pretty fixed on this new course, and I’m not expecting them to divert from it, but maybe we can come up with a fix, mitigating these behaviors, before WP 6.5 is being rolled out later this month ??

    Plugin Author Jeff Starr

    (@specialk)

    Thanks, I am able to repeat the issue using the block editor. Not sure how to resolve from the plugin side of things. It’s a big change in the way code is handled by WordPress. Any ideas welcome.

    Adds: I notice the issue with line breaks does not happen with the “Preformatted” block. Not sure if it helps but thought I would mention.

    • This reply was modified 8 months, 3 weeks ago by Jeff Starr.
    Thread Starter Bjarne Oldrup

    (@oldrup)

    Hey Jeff. Thank you for looking into this. It looks like we might get a fix, here in the 11th hour, after all. Crossing fingers.

    Nice tip with replacing the code block with the pre block. Let’s hope it doesn’t come to that. The code block should work in my opinion.

    Plugin Author Jeff Starr

    (@specialk)

    That is great news, I think it would be a wise move.

    Thanks for your diligence and reporting with this issue.

    Thread Starter Bjarne Oldrup

    (@oldrup)

    Yup. Just tested with RC2. Fix looks good on my end ??

    Plugin Author Jeff Starr

    (@specialk)

    Great news! ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Editing code blocks in WP 6.5 may trigger unwanted line break escaping’ is closed to new replies.