3

I'm working on prettify'ing some auto-generated emails that often have code snippets in them. I want to use Google's prettify project to syntax highlight the code snippets.

How can I invoke prettify on the server, before sending out the email, such that users will still see the highlighted syntax when javascript is disabled in their mail viewers (Outlook). I'm thinking I need some sort of browser emulator since prettify is manipulating the browser DOM.

1 Answer 1

2

Running the plain JavaScript on the server is possible using Rhino or the Google v8 interpreter, but that would mean you'd have to scan the emails, find all the code blocks, write a special call to prettify so it returns the formatted code instead of replacing it on the DOM... not too practical, plus you'd have to have shell access to your server to get v8 going. If you are interested in that, look here: Running V8 Javascript Engine Standalone

Now, the other way would be to use one of the many server-side highlighters like Hyperlight (http://code.google.com/p/hyperlight/) or Pygments (http://pygments.org/)

Lastly, you'd have to include in the emails all the CSS from the themes used by any of the above methods, which isn't too big of a hassle, but increases the size of the email, even if all what was there to highlight was a variable name, for instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.