selection2rtf.js, proof of concept

Forums » General Opera topics » User JavaScript

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

28. March 2008, 13:15:43

profiT

Posts: 453

selection2rtf.js, proof of concept

Just wanted to show this thing off:

selection2rtf.js

Install this script.
Open some page.
Select something.
Press the ugly 'button' that pops up when you have finished selecting.

Works in Opera 9.26 and Opera 9.5 (there is some problem in 9.5 with opening generated rtf-file directly from Opera, but you can save it somewhere and open it yourself).

For now it can handle: usual text, small subset of html-tags (bold, italic and etc), links and images.

It uses the same technique to extract images as convert2phf.js but while convert2phf processes entire page and converts it to HTML-based formats (html with data uri embedded images and mht), this script works with current selection and generates RTF -- the format which has no connections and similarities with HTML, so be aware that total converting will be either not possible or just too complex to implement.

Generated files can be opened in MS Word, or OpenOffice Write.
selection2rtf.js -- exporting selection to Word files (with images and some formatting)
Convert2PHF.js -- saving in single htm or mht file

29. March 2008, 23:22:56

cecilia

Been to the Moon

Posts: 309

yes, selection2rtf.js works

yeah, the button is "ugly" smile
but that doesn't bother me

thanks
Opera Version 12.15 Build 1748 Platform Linux System i686, 2.6.32-47-generic-pae

"When the going gets weird, the weird turn pro" - Hunter S. Thompson

1. April 2008, 14:43:21

profiT

Posts: 453

Have fixed it a little: i forgot to do escaping of curly brackets and backslash (they are control characters in RTF) in output sequence.
selection2rtf.js -- exporting selection to Word files (with images and some formatting)
Convert2PHF.js -- saving in single htm or mht file

2. April 2008, 08:44:09

profiT

Posts: 453

Support for <pre> <code> <sup> and <super> was added.

Also, i have fixed quirks with carriage return that was not recognized as white-space character.
selection2rtf.js -- exporting selection to Word files (with images and some formatting)
Convert2PHF.js -- saving in single htm or mht file

3. April 2008, 01:08:50

cecilia

Been to the Moon

Posts: 309

I think right now the most annoying feature is that the RTF button pops up even if I click on a video (like from you tube)
Opera Version 12.15 Build 1748 Platform Linux System i686, 2.6.32-47-generic-pae

"When the going gets weird, the weird turn pro" - Hunter S. Thompson

3. April 2008, 14:45:06

profiT

Posts: 453

Now ugly button appears only when you have a text selected.
selection2rtf.js -- exporting selection to Word files (with images and some formatting)
Convert2PHF.js -- saving in single htm or mht file

12. August 2009, 01:37:50 (edited)

wakingup

Please say "Hi!" to Georgi

Posts: 128

Hi profiT,

I just tried this, it's great and I mentioned something about it on the wish list. Just to see what would happen I associated rtf files with Windows Live Writer. This opened up a new instance of Live Writer, and a new post, but it never pasted anything (I didn't think it would, but it got all that way...)

Do you suppose there's any way to get this to export and paste to Live Writer?

It just seems to me that your "Ugly Button" might possibly just be an ugly duckling. Could it be a "Blog This" button in disguise? <-- I don't know, I'm just hoping you know how to do it!

-------------------------------------------------------------------------------------------------------------------------------------------

Georgi says "Hello!"

Forums » General Opera topics » User JavaScript