views:

181

answers:

3

I'm going to be including some code in a word document. Specifically some sql statements but this question applies to any sort of language. I'd like to make the code look a bit nicer and easier to read with some highlighting.

Is there any tool that will do syntax highlighting on some code and allow me to copy the result into msword? Preferably in a way that lets someone copy the code back into notepad with no damage.

+1  A: 

I have used eclipse to copy syntax highlighting, font and formatting just by copy/paste. I don't know how reliable it is though it seems to work most of time but the odd time it fails. Eclipse might be more than what you want though as it is a full IDE.

Matt Campbell
A: 

Use a syntax higlighter of your choice.

This will depend on whether it a server or desktop app.

QT has a nice library for syntax higlighting code.

HTMLTidy is good for HTML.

http://qbnz.com/highlighter/

http://code.google.com/p/syntaxhighlighter/

http://doc.trolltech.com/4.4/richtext-syntaxhighlighter.html

Make sure it outputs HTML.

Save the HTML with a .doc extension.

Open in word 2008.

Voila, syntax highlighting in word.

Byron Whitlock
+4  A: 

Quickhighlighter.com can generate html in a variety of languages which you can then put in Word. No download needed.

Sean