code-block-pro
code-block-pro copied to clipboard
Newlines are Discarded from Code Copied to Clipboard
I just noticed that whenever I copy code using the Copy button, the code copied to the clipboard discards newlines (CRLF, etc.). You can see this on the following page.
https://www.circuitstate.com/tutorials/how-to-create-a-standalone-raspberry-pi-pico-c-cpp-project-in-windows-and-build-from-command-line-and-vs-code/
Simply copy any code there using the copy button and paste it into a notepad. The notepad contents look like below for me.
My actual code looks like below.
If copied by drag selection, it works as expected and the newlines are preserved when the code is pasted.
It doesn't happen locally when I try it but I see it happening on your site. Do you want to maybe list out your plugins or try deactivating them again? Not sure if you have that test site still set up.
https://github.com/KevinBatdorf/code-block-pro/assets/1478421/df4a3ed5-e0b8-484f-87ed-eaa3c6cde6da
Interesting. The staging site is sill up. Let me check.
Found it. This time the culprit is the Flying Scripts plugin. It defers loading/executing Js until a user action happens. I use it to delay Google Ads. I have the following keywords to defer the Javascript. See any problem here?
adsbygoogle.js
reactive_library_fy2019.js
show_ads_impl_fy2019.js
recaptcha
I tried removing each of the keywords one by one but had no effect even after removing all of them. Only when I deactivated the plugin, did the Copy button start working correctly.
What's odd is the formatting is being changed before it's even in the browser. It could be because I used the attribute data-code
and they are doing something with that.
For now, I will keep the Flying Scripts plugin deactivated. I don't see a performance impact even after disabling it. So it should be good.
I had a similar issue with LiteSpeed cache. I fixed it by excluding front.js from the Deferred / Delayed JS pipeline.
That's valuable feedback, thank you. I'll look into that
I had a similar issue with LiteSpeed cache. I fixed it by excluding front.js from the Deferred / Delayed JS pipeline.
Hey, thanks a ton for your reply because I would have never resolved this issue without it! I'm still struggling to resolve this issue while the LiteSpeed Cache plugin is enabled. Similarly to you, I added the front.js
file to all excludes inside of Page Optimization > [8] Tuning
as you can see in the image below. That didn't seem to work for me, but I was able to track this issue back to the same plugin because the issue was resolved when I disabled it.
Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.
Is there a setting related to that under the HTML Settings tab there?
Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.
Is there a setting related to that under the HTML Settings tab there?
Gonna take a look for that setting now, but in the meantime...here's a link to their Plugin, Github Repo, and Docs!
Thanks for the feedback. Can you link to the plugin? Ultimately, these html minification plugins/services shounld't be removing whitespace from within HTML attributes. At least not by default.
Is there a setting related to that under the HTML Settings tab there?
It seems disabling the HTML Minify setting in the [3] HTML Settings
tab solves this issue. I removed front.js
from the excludes and as long as the HTML Minify setting was disabled, the copy feature functions as normal.
Thanks for sharing the GitHub. i'll see if I can somehow add an exception so their code doesn't process it by default
Thanks for sharing the GitHub. i'll see if I can somehow add an exception so their code doesn't process it by default
Wow, thanks for being outstanding! Fast replies, helpful solutions, and even looking into adding an exception... I really appreciate all the effort you put into creating and maintaining this plugin as well as helping those who use it! 😄