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

Indentation issue when using copy button #345

Open savioribeiro opened 3 weeks ago

savioribeiro commented 3 weeks ago

Hello!

When I insert a block of code into a post, the indentation is displayed normally. However, when I use the copy button, the indentation is lost.

Apparently this is caused by the cache plugin that I use to minify all the code on the page, W3 Total Cache.

Because the copied code is the same as the one that appears in the page's source code.

Is there any way to solve this issue without having to disable the W3 Total Cache minify feature?

KevinBatdorf commented 3 weeks ago

Thanks for reporting. Do they have any setting to allow html attributes? Seems like a bug in their code to be stripping out valid whitespace like this. You could also not minify html at all for now.

I'll try to dig in and see if there's something I can do to exclude it, or another workaround.

savioribeiro commented 3 weeks ago

Thank you for the quick response.

Here on this page about HTML minification on the official W3 Total Cache website, there is a setting about ignoring comments. But if I understand correctly, it only applies to not removing comments from the source code, not preserving spaces from an element between two comments, for example.

KevinBatdorf commented 3 weeks ago

If you disable the html minify it works? What if you select/deselect the "Line break removal" option? Any difference?

savioribeiro commented 1 week ago

Sorry for the late reply.

I disabled HTML minification and the copy button works perfectly - the indentation is not lost in this case.

The 'Line break removal' was already disabled.