plugin Markdown Special Paste

Plugins for SynWrite and CudaText...
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

plugin Markdown Special Paste

Post by lookoutside »

Dear author, thanks for your great software.

I use Cudatext as a note-taking editor. So I copy and paste URL and html text frequently. I wish Cudatext can support improved url copy-and-paste like edge/chrome:

https://support.microsoft.com/en-us/mic ... 88a30645b4

If it is possible, then I think when I paste in the Cudatext, the result will be like:

for markdown users

Code: Select all

[Text](url)
or

for rst users

Code: Select all

`Text <url>`__
The above example is just an demo about conception. Perhaps Cuda text can leave the setting of templates to the users.

In addition, if we can copying web page to cudatext with an similar way, then the url under the link will not get lost.

Thank you very much!
Last edited by lookoutside on 21.08.2022 06:28, edited 1 time in total.
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post by main Alexey »

tried to write a plugin.
I used 2 templates for 2 lexers from your post.
please try, plugin handles 'on_paste' when URL is in clipboard, and changes pasted text for 2 lexers.
open ZIP file in CudaText, confirm to install.

EDIT: file deleted
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

Post by lookoutside »

Thank you, you are great! Perhaps Cudatext is the first text editor support url paste.

I think I can put forward some useful suggestions in new posts.
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

Post by lookoutside »

main Alexey wrote: please try, plugin handles 'on_paste' when URL is in clipboard
I tried, yes it works as I said but it may be better if you can change the Text place holder to the actual title.

For example, if I copy the url and paste the url of the current post, the result should be:

Code: Select all

[UVviewsoft forums • Post a reply (sourceforge.net)](http://synwrite.sourceforge.net/forums/posting.php?mode=quote&f=20&p=16222)

`UVviewsoft forums • Post a reply (sourceforge.net) <http://synwrite.sourceforge.net/forums/posting.php?mode=quote&f=20&p=16222>`__
The Text are replaced with the web page title. This is a new feature afforded recently by Edge/Chrome if we paste the url in adequate editors which is explained by Microsoft. Perhaps it's hard to implement this feature in text editors. I don't know.

Even so, your plugin is very helpful. It helps to reduce labor work definitely and give me an example to write plugins.
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

Post by lookoutside »

main Alexey wrote:tried to write a plugin.
Sir, I have a question about writing plugin. I know a little about python, but I don't know how to write, test, or debug this kind of code conveniently.

I try to import cudatext using Exterminal, but it does not work. It only works in the cudatext console. How can I get a developing python environment for writing plugin?
Last edited by lookoutside on 21.08.2022 07:58, edited 1 time in total.
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post by main Alexey »

I try to import cudatext using Exterminal, it only works in the cudatext console. How can I get a developing python environment for writing plugin?
I do this: I write the code in file __init__.py and then I run the resulting plugin. if it has errors, Cud will show them in the Console panel (press Ctrl+tilde to show Console).

Now published the plugin 'Special URL Paste'.
it now sets correct webpage title on paste (from the <title> tag). please install from Addons Manager.
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post by main Alexey »

A note: I renamed the folder of plugin: cuda_url_paste -> cuda_special_url_paste;
please reinstall from Addons Manager.
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

Post by lookoutside »

Thank you, it works totally right now. I could not believe you get it down by get the title using requests. It's an amazing idea.

Another question: Can you leave another option for users to paste only the url as before when the "Ctrl + Shift + V" is pressed?
lookoutside
Posts: 51
Joined: 17.08.2022 13:42

Post by lookoutside »

main Alexey wrote:A note: I renamed the folder of plugin: cuda_url_paste -> cuda_special_url_paste;
please reinstall from Addons Manager.
A problem: Some time it takes too long to get the title by requests through network. I think you can set a time-out.
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post by main Alexey »

plugin updated in addons.
- set timeout to 5 sec (you can change it in the __init__.py file - SET_TIMEOUT=5)
- unquote HTML entities
Can you leave another option for users to paste only the url as before when the "Ctrl + Shift + V" is pressed?
I cannot find what is Ctrl+Shift+V in Cud. so you suggest the new plugin command. maybe idea for this: that plugin detects Ctrl or Alt or Shift pressed and skips its work when one of keys is pressed?
Post Reply