BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Copy & paste from code block to nano editor issue

Open jeffshead opened this issue 1 year ago • 2 comments

Attempted Debugging

  • [X] I have read the debugging page

Searched GitHub Issues

  • [X] I have searched GitHub for the issue.

Describe the Scenario

I don't consider this a BookStack bug but since BookStack has code blocks to make it easy to copy/paste code, I believe this "enhancement" is worth considering if it can be implemented.

ISSUE:

When coping multiple lines from a BookStack code block and pasting them into nano, in a terminal window, the new line characters are lost or replaced and some lines are out of order, as depicted in the image below:

missing line breaks

It should look like the image below (copy/paste from EditPad Pro):

with line breaks

Work-around:

Copy code from the BookStack code-block, paste the code into a wordpad app such as EditPad Pro and then copy the text from the wordpad app and paste that into nano.

I get the same results with PuTTY, KiTTY, MobaXterm, etc. I'm working on a Windows PC. Not sure if that matters.

Additional info:

https://github.com/vercel/hyper/issues/1448#issuecomment-367890105 http://savannah.gnu.org/bugs/?49176#comment5

Exact BookStack Version

23.05.2

Log Content

N/A

PHP Version

8.x

Hosting Environment

AlmaLinux 8.8, Docker

jeffshead avatar Jul 02 '23 19:07 jeffshead

Thanks @jeffshead.

Not really sure where to take this for BookStack. We could change line endings depending on platform, which is what it looks like VSCode did, but I am hesitant since as far as I can tell we've always provided \n endings for code blocks, and it's hard to foresee the potential corner cases this change may affect and their significance relative to your scenario. It is something we can control though rather simply via CodeMirror config.

ssddanbrown avatar Jul 03 '23 14:07 ssddanbrown

Having also a problem problem pasting into a console, or emacs... etc

copy/paste this code from a code block:

START TRANSACTION;
WITH delete_needed AS (
 select phone_directory_id from asterisk.v_phone_buttons where compressed_mac is null
)
DELETE FROM
 asterisk.phone_buttons
WHERE
 phone_directory_id IN (SELECT phone_directory_id FROM delete_needed)
RETURNING *
;


And it looks like this when using a straight console 2024-03-15_23-01

The arrows are pointing to non-ascii characters that are getting pasted in... if you paste this into emacs it will completely mash up the paste where it looks like this:

2024-03-15_23-02

kobaz avatar Mar 16 '24 03:03 kobaz