json.js 670 B

123456789101112131415161718
  1. /* vim: set expandtab sw=4 ts=4 sts=4: */
  2. /**
  3. * JSON syntax highlighting transformation plugin
  4. */
  5. AJAX.registerOnload('transformations/json.js', function () {
  6. var $elm = $('#page_content').find('code.json');
  7. $elm.each(function () {
  8. var $json = $(this);
  9. var $pre = $json.find('pre');
  10. /* We only care about visible elements to avoid double processing */
  11. if ($pre.is(':visible')) {
  12. var $highlight = $('<div class="json-highlight cm-s-default"></div>');
  13. $json.append($highlight);
  14. CodeMirror.runMode($json.text(), 'application/json', $highlight[0]);
  15. $pre.hide();
  16. }
  17. });
  18. });