143 lines
3.9 KiB
HTML
143 lines
3.9 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>dojox.highlight.pygments - syntax highlighting | The Dojo Toolkit</title>
|
||
|
<style type="text/css">
|
||
|
@import "../../../dijit/tests/css/dijitTests.css";
|
||
|
|
||
|
/* CSS rules for debugging */
|
||
|
|
||
|
pre code[class]:after {
|
||
|
content: 'highlight: ' attr(class);
|
||
|
display: block; text-align: right;
|
||
|
font-size: smaller;
|
||
|
color: #CCC; background: white;
|
||
|
border-top: solid 1px;
|
||
|
padding-top: 0.5em;
|
||
|
}
|
||
|
|
||
|
pre code {
|
||
|
display: block;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<!-- a sample set of definitions to use as a foundation to color your code -->
|
||
|
<link rel="stylesheet" type="text/css" href="../resources/pygments/default.css" />
|
||
|
|
||
|
<script type="text/javascript" djConfig="parseOnLoad: true, isDebug: true" src="../../../dojo/dojo.js"></script>
|
||
|
<!--
|
||
|
<script type="text/javascript" src="../_base.js"></script>
|
||
|
<script type="text/javascript" src="../languages/pygments/xml.js"></script>
|
||
|
<script type="text/javascript" src="../languages/pygments/html.js"></script>
|
||
|
<script type="text/javascript" src="../languages/pygments/css.js"></script>
|
||
|
<script type="text/javascript" src="../languages/pygments/javascript.js"></script>
|
||
|
-->
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
dojo.require("dojox.highlight");
|
||
|
/*
|
||
|
dojo.require("dojox.highlight.languages.pygments.xml");
|
||
|
dojo.require("dojox.highlight.languages.pygments.html");
|
||
|
dojo.require("dojox.highlight.languages.pygments.css");
|
||
|
dojo.require("dojox.highlight.languages.pygments.javascript");
|
||
|
*/
|
||
|
dojo.require("dojox.highlight.languages.pygments._www");
|
||
|
dojo.require("dojo.parser");
|
||
|
|
||
|
dojo.addOnLoad(function(){
|
||
|
var sel = dojo.byId("theme"),
|
||
|
sty = dojo.query("link[rel='stylesheet']", document.head)[0];
|
||
|
dojo.query("option[value='default']", sel)[0].selected = "selected";
|
||
|
dojo.connect(sel, "onchange", function(){
|
||
|
sty.href = "../resources/pygments/" + sel.value + ".css";
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>Test Pygments-based highlighting</h1>
|
||
|
|
||
|
<p>Current theme from the pygments set:
|
||
|
<select id="theme">
|
||
|
<option value="autumn">Autumn</option>
|
||
|
<option value="borland">Borland</option>
|
||
|
<option value="colorful">Colorful</option>
|
||
|
<option value="default">Default</option>
|
||
|
<option value="emacs">Emacs</option>
|
||
|
<option value="friendly">Friendly</option>
|
||
|
<option value="fruity">Fruity</option>
|
||
|
<option value="manni">Manni</option>
|
||
|
<option value="murphy">Murphy</option>
|
||
|
<option value="native">Native</option>
|
||
|
<option value="pastie">Pastie</option>
|
||
|
<option value="perldoc">Perldoc</option>
|
||
|
<option value="trac">Trac</option>
|
||
|
</select>
|
||
|
</p>
|
||
|
|
||
|
<p>Javascript:</p>
|
||
|
|
||
|
<pre><code dojoType="dojox.highlight.Code">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</code></pre>
|
||
|
|
||
|
<p>Some CSS code:</p>
|
||
|
|
||
|
<pre><code dojoType="dojox.highlight.Code">body,
|
||
|
html {
|
||
|
font: Tahoma, Arial, sans-serif;
|
||
|
}
|
||
|
|
||
|
#content {
|
||
|
width: 100%; /* test comment */
|
||
|
height: 100%
|
||
|
}
|
||
|
|
||
|
p[lang=ru] {
|
||
|
color: red;
|
||
|
}
|
||
|
</pre></code>
|
||
|
|
||
|
<p>Some HTML code:</p>
|
||
|
|
||
|
<pre><code dojoType="dojox.highlight.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>
|
||
|
</code></pre>
|
||
|
|
||
|
<p>A custom XML document:</p>
|
||
|
|
||
|
<pre><code dojoType="dojox.highlight.Code"><?xml version="1.0"?>
|
||
|
<response value="ok">
|
||
|
<text>Ok</text>
|
||
|
<comment/>
|
||
|
<ns:description><![CDATA[
|
||
|
CDATA is <not> magical.
|
||
|
]]></ns:description>
|
||
|
</response>
|
||
|
</code></pre>
|
||
|
|
||
|
</body>
|
||
|
</html>
|