-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add line break to end of each code block line #62
Conversation
Hey @nobkd |
I selected multiple lines of code in the code block by hand and copied them. Then I paste them in some editor. I checked Firefox on Linux (Firefox 118.0.1) and Windows (Firefox 118.0.2), and it happens on both. |
I've checked again, and the EDIT: I understand... Tags that only contain newlines are removed: mdc/src/runtime/parser/compiler.ts Lines 71 to 77 in 31f68b6
It's alright to do this, but not when they are within a code block. |
The version, I just pushed, only works for lines that contain code / text. Not sure how to handle that while still keeping general newline stripping... Edit: I've played around a bit:
Do you have better ideas? |
@farnabaz do you have thoughts about how to properly solve this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nobkd
I've checked in Firefox and copy seems fine now. As for empty lines just added an empty line placeholder which we keep it in compiler
I don't think, that newlines should be added to inline The code where the (Also not sure, if an empty line placeholder gets added to empty inline Maybe it does not even change anything, when copying, as the newline is not in a EDIT: It does not make sense, that the inline |
Similar to nuxt/content#2008 to fix nuxt/content#1883
Current solution not working.
Not even sure, why this shouldn't work. If you have any idea, please let me know!
Do I have to add it as text node of real element? 🤔
Would have to traverse hast to find the last text node in line and add
\n
to its value.For empty lines, will probably have to add new span?
(Maybe applying
\200b
to non-empty lines because of adding\n
to empty ones?)