dojox.highlight.pygments - syntax highlighting | The Dojo Toolkit

# Test Pygments-based highlighting

Current theme from the pygments set:

Javascript:

    function initHighlight(block) {
      if (block.className.search(/\bno\-highlight\b/) != -1)
        return false;
      try {
        blockText(block);
      } catch (e) {
        if (e == 'Complex markup')
          return;
      }//try
      var classes = block.className.split(/\s+/);
      for (var i = 0; i < classes.length; i++) {
        if (LANGUAGES[classes[i]]) {
          highlightLanguage(block, classes[i]);
          return;
        }//if
      }//for
      highlightAuto(block);
    }//initHighlight

Some CSS code:

    body,
    html {
      font: Tahoma, Arial, sans-serif;
    }

    #content {
      width: 100%; /* test comment */
      height: 100%
    }

    p[lang=ru] {
      color: red;
    }

Some HTML code:

    <head>
      <title>Title</title>
    <body>
      <p class="something">Something</p>
      <p class=something>Something</p>
      <!-- comment -->
      <p class>Something</p>
      <p class="something" title="p">Something</p>
    </body>

A custom XML document:

    <?xml version="1.0"?>
    <response value="ok">
      <text>Ok</text>
      <comment/>
      <ns:description><![CDATA[
      CDATA is <not> magical.
      ]]></ns:description>
    </response>