n1k0 / SublimeHighlight

A humble SublimeText package for exporting highlighted code as RTF or HTML
https://github.com/n1k0/SublimeHighlight
MIT License
788 stars 105 forks source link

OS X - Fix pasting RTF into web rich text editors #64

Closed jgillick closed 8 years ago

jgillick commented 8 years ago

Currently when you copy as rich text, it will not keep the correct colors and formatting when pasting into web-based rich text editors (Google Docs, Webmail and other WYSIWYG). The problem is that browsers want to paste from the HTML clipboard type and pbcopy only fills the plain text and RTF types of the clipboard.

This fix uses a simple applescript to fill the clipboard with the content as plain text, RTF and HTML. Then when you paste, it will retain the colors and formatting.

n1k0 commented 8 years ago

Looks good! I don't own a Mac anymore, so I couldn't test the patch. I believe it works and adds value for Mac users though, so merging this.