Skip to content
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

Copying raw text includes a bunch of QT formatting rules #817

Open
nsrosenqvist opened this issue Dec 31, 2017 · 17 comments
Open

Copying raw text includes a bunch of QT formatting rules #817

nsrosenqvist opened this issue Dec 31, 2017 · 17 comments

Comments

@nsrosenqvist
Copy link

Expected behaviour

Copying the text from the editor should copy it as raw text without formatting rules (since rules are defined as markdown)

Actual behaviour

When I copy from the editor into a web browser (e.g. a blog post) I get a bunch of extra tags that seem to contain QT formatting rules for every paragraph.

Comments

Since it's a markdown text it's assumed that there shouldn't styling rules copied as well since the rules are defined in the text data. It's also not a rich text editor so even if it wasn't markdown then these rules shouldn't be included on copy.

@pbek
Copy link
Owner

pbek commented Dec 31, 2017

I'm sorry, that's the way Qt handles that in a QPlainTextEdit. If your destination where you paste the text can handle rich text it will get rich text. Usually the destination decides if plain or rich text is used while pasting.

But you should be able to be able to copy plain text to the clipboard pretty easily with the help of the scripting engine.

There are the parts that you need:

@pbek
Copy link
Owner

pbek commented Dec 31, 2017

If you create a script you can make a pull requests at https://github.com/qownnotes/scripts

@pbek
Copy link
Owner

pbek commented Jan 1, 2018

Hm... I tried to paste text from the QOwnNotes note edit panel to LibreOffice Writer or an online editor and didn't get any formatting or "QT formatting rules"... How did you manage to get those (and please fill out the full issue template)?

@nsrosenqvist
Copy link
Author

@pbek, I pasted it into a web browser wysiwyg editor on a blogging platform, more specifically TinyLetter (I believe it uses the CKE editor). It shows when I switch to the "show source" view.

If I have a document like this:

Note 2018-01-22T23.49.45
========================

Testing testing

Then it results in:

<div>
<style type="text/css">p, li { white-space: pre-wrap; }
</style>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:12;">Note 2018-01-22T23.49.45</p>

<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:101;">========================</p>

<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&nbsp;</p>

<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Testing testing</p>
</div>

@pbek
Copy link
Owner

pbek commented Jan 22, 2018

It seems that the editor pastes the rich-text of the clipboard as html and not as rich-text... I can't do anything about that. What happens if you copy and paste text from a webpage in a webbrowser?

@nsrosenqvist
Copy link
Author

Same thing, which is to be expected. But isn't there something that can be configured so that just plain text is copied by default? You said the component name was QPlainTextEdit, shouldn't it then support plain text when copied?

@pbek
Copy link
Owner

pbek commented Jan 25, 2018

Yes, and every other rich text editor interprets the pasted text as plain-text...

@nsrosenqvist
Copy link
Author

Do you reckon it should be reported as an upstream bug?

@pbek
Copy link
Owner

pbek commented Jan 25, 2018

Of course you could try...
But I couldn't reproduce your problem in https://ckeditor.com/ckeditor-5-builds/.

@nsrosenqvist
Copy link
Author

Hmm, yeah. I figured that other editors might simply be filtering out the incorrect formatting but when I'm pasting it into Gedit I get just the plain text as well. I guess this issue might be just affecting a too specific use case. Feel free to close this issue if you want to, I'll work around this when using the Tinyletter web service by copy-pasting into gedit before I put it into the web wysiwyg editor.

@andreas-breitbach
Copy link

Hello there,

I MIGHT have kind of the same issues:

The text renders as pictured in the screen shot. Using the <> (greater/lower than) mixes up the rendering. Looking up the ">", I see that's the HTML Escape code for said lower/greater than. I think it worked a few versions ago; I've just started using QOwnnotes. Rendering the same code directly via Plantuml works as expected, see graphics below.

BTW: I'm amazed at how easy this is compared to Evernote whilst giving me a feature set EN can't dream aboout :)

Best regards,
Andreas

grafik

test
test_001

@pbek
Copy link
Owner

pbek commented Mar 26, 2018

I'm not exactly sure what you did. This current "issue" was about pasting text from QOwnNotes into a special online editor.

BTW: I'm amazed at how easy this is compared to Evernote whilst giving me a feature set EN can't dream aboout :)

Hehe, I'm happy you like it. :) Were you using a script to get the rendering in your screenshot on the right side?

@andreas-breitbach
Copy link

I'm not exactly sure what you did. This current "issue" was about pasting text from QOwnNotes into a special online editor.
Were you using a script to get the rendering in your screenshot on the right side?

Yeah, I could have elaborated a little bit more on that…
Yes, im using render-plantuml. Expected behaviour with this script would be the rendering as you see in the screenshots. What I get is this Syntax error, which complains that &gt;could be wrong. This &gt; is the HTML escape code for >, which got me thinking that the Markdown (and in turn, the Plantuml-Section), is parsed as HTML (or some other language containing escape codes) at someplace during the rendering. This might as well mix up the Plantuml, making the > useless.

Right now I checked if there's anything else in Plantuml, that would be rendered the wrong way - and found some: "ends up as &quot; (below).

I don't really know how where to go from here/if this might be a bug with render-plantuml, QPlainTextEdit, or Plantuml (which works when started from a command line in the directory with the files, rendering them as it should).

grafik

@pbek
Copy link
Owner

pbek commented Mar 28, 2018

@nikhilw, you did render-plantuml, any insights?

@pbek
Copy link
Owner

pbek commented Mar 28, 2018

@andreas-breitbach I guess it would be best to open an issue at https://github.com/qownnotes/scripts/issues

@nikhilw
Copy link

nikhilw commented Apr 10, 2018

I am able to reproduce this issue. Will work on it. @andreas-breitbach, it would be easier to track it if you could add it to scripts repository as @pbek suggested.

@nsrosenqvist I have seen similar behaviour when copying text or code from certain IDEs as well, like Eclipse/Idea. What you are doing, pasting into a plain text editor and copying from there to remove the mark-up is what is needed sometimes.

@andreas-breitbach
Copy link

@nikhilw @pbek Thanks for the reminder (Easter holidays made things complicated for me), I added it to the scripts repository as Issue 27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants