Search code examples
javascriptjquerypretty-printprettify

How do I use google's code prettify on a target element?


I'm currently using the google prettify script prettyPrint. It functions properly, except that it only has the one function call to do the whole page:

prettyPrint();

Ideally I'd like a jquery wrapper that allows:

$("#myelem").prettyPrint();

However this would also suffice:

prettyPrint('myElem');

I have a lot of <pre> tags and initializing them all at the same time is overkill. how do I target a specific element with prettyPrint?


Solution

  • I found a replacement: http://softwaremaniacs.org/soft/highlight/en/ after reading this overflow: How to write an HTML JSON AJAX test harness with prettify, syntax highlighted JSON result?