I am trying to use a Javascript code prefix and ask a question.
If I do not assign class="prettyprint" to <pre> in static html, but you want to apply printprint later (for example, when the user clicks the colorize button on my web page) , how can I achieve this
It's pretty easy to modify the source file run_prettify.js or prettify.js because I'm going to use it offline.
My experiment:
Writing try-delay-class.html:
<html> <head> <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> </head> See it: <pre> class Voila { public: // Voila static const string VOILA = "Voila"; // will not interfere with embedded <a href="#voila1">tags</a>. } </pre> </html>
Open in Chrome v26, raise the console, do:
pres=document.getElementsByTagName('pre') pres[0].className+=" prettyprint"
The syntax color does not appear.

source share