KevinBatdorf / code-block-pro

A Gutenberg code block with syntax highlighting powered by VS Code
https://code-block-pro.com
132 stars 10 forks source link

Adding footnotes mangles all Code Block Pro blocks #329

Open wadetregaskis opened 4 months ago

wadetregaskis commented 4 months ago

Whenever a footnote is added, all Code Block Pro blocks on the page mangle their contents, replacing actual line returns with the literal text <br>.

This has been happening for a while (months or more), but I feel like it didn't always happen.

WordPress 6.5.5 with Code Block Pro 1.26.4 currently.

KevinBatdorf commented 4 months ago

Are you adding something within the code block or outside in another block?

A <br> should not render as a new line within the code block.

Am I understanding it correctly? Do you have a URL or a screenshot?

wadetregaskis commented 4 months ago

That's correct.

The footnote is added outside the code block. e.g.:


Before

If I now place the cursor after the word "etc" and insert a footnote, it immediately becomes:


After

Worse, this cannot be undone (the undo arrow in the WordPress toolbar is enabled but does nothing when clicked, and likewise ⌘Z does nothing).

KevinBatdorf commented 4 months ago

Is the footnote block a plugin? Maybe I can debug what's going on if I reproduce it.

wadetregaskis commented 4 months ago

It's built into WordPress (since version 6.3).

KevinBatdorf commented 4 months ago

Okay I thought so but couldn't find it. I'll look into it and follow up when i figure out what's going on.

KevinBatdorf commented 4 months ago

Looks like this broke in 6.5 specifically. I'll need to debug some more to see if there's something I can do to intercept their code. It seems like they are re-injecting the block but mangling the formatting. Further, like you mention, it doesn't add to the edit history. Might need to patch the footnotes block, which could take time.

For now, maybe you can add the footnotes before the blocks? I know that's not very convenient but I can't think of any other temporary workaround.

wadetregaskis commented 4 months ago

Yeah, that's essentially what I've been trying to do.

Thanks for looking into it. Is it a WordPress bug? It sounds like it shouldn't be mucking with your plug-in's block.