blob: 6bdced626cd82a3ccbb3aee9068d4fa9aa397e00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<!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>
|