prettify-extension.js 604 B

123456789101112131415161718192021222324
  1. // Stolen from StackOverflow. Find all </code><pre><code>
  2. // elements on the page and add the "prettyprint" style. If at least one
  3. // prettyprint element was found, call the Google Prettify prettyPrint() API.
  4. //http://sstatic.net/so/js/master.js?v=6523
  5. function styleCode()
  6. {
  7. if (typeof disableStyleCode != "undefined")
  8. {
  9. return;
  10. }
  11. var a = false;
  12. $("pre code").parent().each(function()
  13. {
  14. if (!$(this).hasClass("prettyprint"))
  15. {
  16. $(this).addClass("prettyprint");
  17. a = true
  18. }
  19. });
  20. if (a) { prettyPrint() }
  21. }