CryptoPaste icon indicating copy to clipboard operation
CryptoPaste copied to clipboard

Support syntax for languages while entering paste

Open anshuman73 opened this issue 7 years ago • 7 comments

Supporting syntax colouring could be a potential feature to build in the future

anshuman73 avatar May 23 '17 15:05 anshuman73

Do you mean updating Highlight.js? Or are you proposing something else?

Kage avatar Jun 01 '17 18:06 Kage

@anshuman73 Ping, can you update please?

Kage avatar Jun 11 '17 01:06 Kage

Hi, sorry for the delayed response. I was suggesting setting Syntax highlighting for languages while the text is being entered.

currently, the viewer chooses the language to highlight the syntax for, wouldn't it be better if the paster can set the syntax too and the viewer gets that syntax highlighting automatically ?

anshuman73 avatar Jun 14 '17 19:06 anshuman73

A potential way could be to store the language in the crypt, but (with my limited cryptographic knowledge), I believe it would make the crypt insecure.

anshuman73 avatar Jun 14 '17 19:06 anshuman73

I had thought about some method of storing a language pre-set (e.g. injecting a language marker into the paste before being encrypted), but I decided not to namely since I wasn't sure how to do the whole thing well.

I don't know of a good way to take Highlight.js and apply it to a rich text editor. If you have some idea, I'd be delighted to review a pull request.

Kage avatar Jun 15 '17 11:06 Kage

After looking around, it appears CodeMirror would be the best option here. It would need to make sure to invoke the cmObj.toTextArea() function before doing the in-browser encryption. Also needs to provide a selection for languages (listed from CodeMirror.modes object), then I believe use cmObj.setOption('mode', '<language>') to change them.

Kage avatar Sep 09 '17 21:09 Kage

Hi, if you want to put add-on like code beautifier you can find libraries on the internet and integrate it

remadrivan avatar Dec 15 '19 12:12 remadrivan

@adrivanrex You're more than welcome to submit a pull request with that or any suitable syntax highlighting library added.

Kage avatar Dec 20 '19 08:12 Kage

trapizoid

remadrivan avatar Oct 23 '22 02:10 remadrivan

Unlock

remadrivan avatar Nov 23 '22 08:11 remadrivan