[ANN] Copy as HTML 0.1

This is a little plugin to copy text from the editor with all (well, almost all) formatting included as HTML.
It copies the current editor selection (or the complete buffer if no selection).
My primary intention was to quickly copy snippets of code to larger documents.
Differences to Idea's built-in HTML export:

  • Result does not include <html> and <body> text, so it's ready to be inserted into another HTML document.

  • Preserves much more formatting, e.g. highlights for member variables, method declarations, etc.

('Underwaved' effect is converted to plain underline.)

  • Uses CSS instead of old style tags.

(Which may or may not be a good thing. Works fine on Firefox and IE 6. Java's HTML renderer produces garbage, though.)

  • Options to include the editor's warning/error highlighting and a thin border (see IDE Settings -> Copy as HTML).

  • Line numbers are included iff they are currently shown in the editor (see Idea's View menu).


Source code will be available soon.
Future plans: Configurable formatting (e.g. to post in blogs or forums that need special tags).

Credits and many thanks to Maxim Shafirov for patiently answering so many questions in a row and to Bas Leijdekkers
and Maxim Mossienko for helping out with action registration.

Oh yeah: If anybody has a nice icon suitable for "Copy as HTML" semantics, I would be very grateful.

4 comments
Comment actions Permalink

Moinmoin!

Hey Stephen,

Your plugin is really cool! I especially like the fact that this is not just for Java source files but all file types. A few suggestions for enhancements that come to my mind:

  • Allow an option to produce a complete HTML file (including <html> and <body> tags and configurable <head> section)

  • Allow to produce a whole set of HTML files from a group of sources

  • Allow interlinking of the HTML files produced (like the links in IDEA when hovering over a class or method name with CTRL pressed)


Regards,
Jens

0
Comment actions Permalink

Hummel Hummel!

  • Allow an option to produce a complete HTML file (including <html> and <body> tags and configurable <head> section)

Yeah, that's on my list. Only I currently donÄt have time to do it properly (with variable substitution for file name, background color, etc.)

  • Allow to produce a whole set of HTML files from a group of sources

  • Allow interlinking of the HTML files produced (like the links in IDEA when hovering over a class or method name with CTRL pressed)

That would be nice, but currently I just don't know how to do that: Currently I use the open editor a lot to determine the correct color, font style etc.
I guess that's also the reason why the built-in HTML export only gives limited formatting.

0
Comment actions Permalink

And here comes version 0.2:
You can now copy/paste directly into OpenOffice or any other word processor that can interprete the html:
- by default the html gets copied both as plain text (text/plain) and with html mime type (text/html)
- your editor will pick the most aproppriate format
- you can select a specific format in settings

I only tested this on Windows with OpenOffice. Using Java to copy a mime type "text/html" is a little tricky. Thanks to Peter Büttner for a workaround: http://www.peterbuettner.de/develop/javasnippets/clipHtml/index.html

I will check on Linux and WinWord soon.

0
Comment actions Permalink

A few suggestions for enhancements
that come to my mind:


Here's one more:

  • Take the current code folding into account.


Best regards,
Jens

0

Please sign in to leave a comment.