views:

31

answers:

2

Visual Studio has a plugin that allows one to copy code from any editor (C#, HTML, XML) and then paste it with HTML formatting that preserves the syntax highlighting, etc.

This is very handy for publishing code samples/examples to a wep page/blog. I have seen one old (2006?) plugin for java to html conversion, but are there any broader solutions similar to the Visual studio plugin.

Really what I am looking for is a way to select and copy a syntax-colored block of text in Eclipse and paste it as formatted html+css.

Does such a thing exist?

+1  A: 

Although I don't know of such plug-ins, but generally pasting the syntax-highlighted text into Word or OpenOffice maintains its formatting, so using their HTML export (possibly the one of OpenOffice is useful here, as it provides simpler result, AFAIK).

Zoltán Ujhelyi
Hmm...I just tried this and still couldn't get any syntax highlighting. Both Windows Live Writer (which accepts formatted text from visual studio) and open office saw this as plain text (even with a "paste special" operation). Can you confirm that this works for you?
ee
I tried it right know - I selected a buch of Java code, and pasted in into OpenOffice, it is syntax highlighted.If it doesn't work for you, then this might be an OSX-only feature.
Zoltán Ujhelyi
Ah..that would explain it (This is on a windows box). Thanks for clarifying
ee
+1  A: 

Eclipse based solutions

Use the Java2Html plugin (this is maybe the plugin you were referring to):

This tool converts Java source code to HTML, XHTML and LaTeX with syntax highlighting.

There is also the CodeSnippet plugin:

CodeSnippet is a set of Eclipse plug-ins to convert Ant, Java, Properties, CSS, DTD, HTML, and XML source code (complete files or snippets) to HTML with syntax highlighting

Non Eclipse based

Use the online Source Code Formatter for Blogger, Blogspot, Blog & Blogging, Format Formatting Tool:

Source Code Beautifier And Formatter For Blogger and Websites, Format Source Code , Format Source code for blog or blogging & website, Online line source code formatter tool, blogger code format tool, Format source code for blogspot,Insert formatted source code

Pascal Thivent
I'm sure there is another nice plugin (that I was using at some time) but I can't find it back.
Pascal Thivent
Great! Thanks. The Java2Html was the one i had seen. Trying the Codesnippet now. (awarding you answer, instead of self answering)
ee
Codesnippet does the job. Had to get all the plugin and feature files into the right place (one for each editor type you want supported), but now I am good to go. Thanks!
ee
@ee You're welcome, glad it was useful.
Pascal Thivent