-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
PR: Add the ability to copy text and export files with syntax highlighting #25552
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
base: master
Are you sure you want to change the base?
Conversation
|
@ccordoba12 I see that all the conda tests are failing due to the new requirement. (also 3.9 tests are failing on type annotation that I forgot was 3.10+) Is there some way to pull the pip package into conda? It's also a really simple stdlib-only single-file library with a permissive license if we want to inline it. |
Yep, that's because Instructions for that are available in this repo. But let me know if you don't have much experience with packaging and I'll give you a hand with that.
I took a look at your last commit and I think you only need to add |
I have never really done any packaging at all. I'm sure I could give it a look and figure it out, but I wouldn't mind the help either.
Yah, I forgot I could do that.. I'll add them back in. |
somehow initially started using an undocumented property which evidently doesn't work on some systems. change to intended property.
I took a quick look at the package and I see two problems with it:
So, could you replace it with a better maintained dependency that allows us to support RTF? |
CAM-Gerlach
left a comment
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.
I tested both the copy/paste and the export functionality in both formats on Windows and with LibreOffice, plain text editors and various applications, and everything seemed to mostly work well. With that in mind, it seems there isn't a strong disadvantage to including the HTML version in the clipboard for applications that want it that would justify the complexity of a separate action, menu item, keyboard shortcut, etc. as the plain text version still seems to work fine with plain text applications as before.
One thing, though--it seems like it uses the dark theme colors but a light theme background, rendering the text low contrast and in some cases (especially non-specially-highlighted text) almost unreadable. I'm not sure how feasible it is with the existing theme infra and/or with @conradolandia 's upcoming changes, but it would be great if we could use the light version of the current theme if available (not sure whether to fall back to the current theme or the Spyder light theme if the current theme doesn't have a light version, as most of them don't besides the default and a few popular ones).
Also in RTF, indentation was double what it should be (8 spaces instead of 4 for each indent); for HTML it was correct.
Finally, see the suggestions for a couple other comments and various minor typo, UI text, docstring and formatting/convention fixes. As a reminder, you can apply them all in one go by navigating to the Files tab, clicking Add to batch on each suggestion, and then once they are all added, clicking the Commit button at the top right.
Good point. I think this is something we should address before merging this PR. |
Hi, I'm the author of said package. The only reason it hasn't seen updates in all these years is because I wasn't sure if anyone was still using it! I'd be happy to update it for modern use, complete with wheel releases. Give me a day or two to modernise the tooling and publish a new release tested against current Python releases. Would that help? |
Sure, thanks a lot for your help @mjpieters! |
Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
I'm currently just pulling the actual formatting from each edit: I found a possible solution that at least seems to work on MS Word: for background color On the other hand; for copying html, it seems adding
I do like the idea of copying exactly the style on screen if possible, but maybe for RTF specifically we just resort to a default light theme? @mjpieters Thanks again for giving this a look! |
I released rtfunicode 2.1, compatible with Python 3.10 and up*, complete with a wheel. As a bonus, the code is now also type-annotated. *) I had to bump the minimal supported version so I could also run Ruff and Pyright; 3.10 is the oldest still-supported Python version. Happy to extend this down if that's still needed here. |
Spyder still tests against 3.9, and I actually ran up against that in this PR earlier trying to use annotations with |
I just released rtfunicode version 2.2, which lowered the minimum Python version to 3.9. I'll raise it again for 2.3 however, as keeping 3.9 requires conditional dev dependencies and that all complicates maintenaince. So if you pin your depenency on |


Description of Changes
Added the ability to copy as html in order to include syntax formatting (text color, bold, and italic).
Media1.mp4
.toHtmlmethods (onQTextCursor.selection()andQTextDocument) do not seem to capture formatting applied by aQSyntaxHighlighter.Issue(s) Resolved
Fixes #25534
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: athompson673