Copy paste problem on KDE

copy/pastekde

I've been extremely annoyed with this issue for a while. I'm using TeXMaker on KDE to write my class notes in LaTeX and I sometimes need to copy paste text from it to some other applications while editing, the flashcard program Anki being one of them.

TeXMaker uses syntax highlighting and for some reason hitting copy paste will copy the color tags with it together with tags for formatting. The end result is that Anki will treat the color tags as part of the LaTeX code and feed the code together with color tags into LaTeX, which of course makes any LaTeX compile fail.

It seems like KDE apps include formatting and color data in the data that is sent to the clipboard. In other words it won't just be a sequence consisting of the characters you've typed, but it will contain various tags that essentially look like HTML.

Anyone else stumbled on the same problem? Any way to fix it?

Best Answer

What you need is a middleman in the form of a very simple text editor that is not using the Qt Toolkit. The Qt widgets will include the formatting information on a cut/copy operation, and if the Qt widget that it is pasted to accepts the formatting, the formatting follows. I have experienced this in my own PyQt applications. However, if the text is pasted to an X11 client that only accepts plain text, the formatting will not be pasted. You can then select/copy from the middleman and paste into Anki.

Note: It may be possible to use another Qt application, since that depends on how the QtextEdit is configured in the application, although this depends on trial and error when determining the application you will need to serve as middleman.

Related Question