jQuery 语法着色插件 Chili

温馨提示:使用该语法着色插件时可能会要将代码转换成Unicode,在线转码工具能够为你将Native转换为Unicode

效果:

PRE不带有 class="ln"

PRE不带有 class="ln" 代码将不会有行号



/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define('GESHI_NEVER', 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define('GESHI_MAYBE', 1);
/** Strict mode always applies */
define('GESHI_ALWAYS', 2);

// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define('GESHI_SEARCH', 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define('GESHI_REPLACE', 1);
/** The key of the regex array defining any modifiers to the regular expression */
define('GESHI_MODIFIERS', 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define('GESHI_BEFORE', 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define('GESHI_AFTER', 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp's html tag class */
define('GESHI_CLASS', 5);

/** Used in language files to mark comments */
define('GESHI_COMMENTS', 0);

// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define('GESHI_ERROR_NO_INPUT', 1);
/** The language specified does not exist */
define('GESHI_ERROR_NO_SUCH_LANG', 2);
/** GeSHi could not open a file for reading (generally a language file) */
define('GESHI_ERROR_FILE_NOT_READABLE', 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define('GESHI_ERROR_INVALID_HEADER_TYPE', 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define('GESHI_ERROR_INVALID_LINE_NUMBER_TYPE', 5);
/**#@-*/


PRE带有 class="ln-"

PRE带有 class="ln-" 代码将会有从1开始的行号.


/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define('GESHI_NEVER', 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define('GESHI_MAYBE', 1);
/** Strict mode always applies */
define('GESHI_ALWAYS', 2);

// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define('GESHI_SEARCH', 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define('GESHI_REPLACE', 1);
/** The key of the regex array defining any modifiers to the regular expression */
define('GESHI_MODIFIERS', 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define('GESHI_BEFORE', 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define('GESHI_AFTER', 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp's html tag class */
define('GESHI_CLASS', 5);

/** Used in language files to mark comments */
define('GESHI_COMMENTS', 0);

// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define('GESHI_ERROR_NO_INPUT', 1);
/** The language specified does not exist */
define('GESHI_ERROR_NO_SUCH_LANG', 2);
/** GeSHi could not open a file for reading (generally a language file) */
define('GESHI_ERROR_FILE_NOT_READABLE', 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define('GESHI_ERROR_INVALID_HEADER_TYPE', 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define('GESHI_ERROR_INVALID_LINE_NUMBER_TYPE', 5);
/**#@-*/

PRE带有 class="ln-172"

PRE带有 class="ln-N" 代码将带有从指定数字N开始的行号


/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define('GESHI_NEVER', 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define('GESHI_MAYBE', 1);
/** Strict mode always applies */
define('GESHI_ALWAYS', 2);

// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define('GESHI_SEARCH', 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define('GESHI_REPLACE', 1);
/** The key of the regex array defining any modifiers to the regular expression */
define('GESHI_MODIFIERS', 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define('GESHI_BEFORE', 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define('GESHI_AFTER', 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp's html tag class */
define('GESHI_CLASS', 5);

/** Used in language files to mark comments */
define('GESHI_COMMENTS', 0);

// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define('GESHI_ERROR_NO_INPUT', 1);
/** The language specified does not exist */
define('GESHI_ERROR_NO_SUCH_LANG', 2);
/** GeSHi could not open a file for reading (generally a language file) */
define('GESHI_ERROR_FILE_NOT_READABLE', 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define('GESHI_ERROR_INVALID_HEADER_TYPE', 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define('GESHI_ERROR_INVALID_LINE_NUMBER_TYPE', 5);
/**#@-*/

PRE带有 class="ln-172-access-private"

第一个PRE带有 class="ln-172-access-private" 代码会带有从制定行数开始编号的行号


/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define('GESHI_NEVER', 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define('GESHI_MAYBE', 1);
/** Strict mode always applies */
define('GESHI_ALWAYS', 2);

PRE带有 class="ln-172-access-private"

如何之前也有PER带有 class="ln-172-access-private",那么该段代码将接上个PRE的最大编号开始显示行号。

 
// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define('GESHI_SEARCH', 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define('GESHI_REPLACE', 1);
/** The key of the regex array defining any modifiers to the regular expression */
define('GESHI_MODIFIERS', 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define('GESHI_BEFORE', 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define('GESHI_AFTER', 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp's html tag class */
define('GESHI_CLASS', 5);

/** Used in language files to mark comments */
define('GESHI_COMMENTS', 0);

代码:   在线编辑

?
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<style>
    .section{padding:10px;margin:10px 0;background-color:#eee;border-radius:5px;}
</style>
<script type="text/javascript" src="http://www.ostools.net/js/jquery/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://www.ostools.net/uploads/jquery/highlighter/chili/recipes.js"></script>
<script id="setup" type="text/javascript">
ChiliBook.automatic = true;
ChiliBook.lineNumbers = false;
</script>
<div class="section">
<h3>PRE不带有 class="ln"</h3>
<p>PRE不带有 class="ln" 代码将不会有行号</p>
<pre>
<code class="php">
/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define(&#39;GESHI_NEVER&#39;, 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define(&#39;GESHI_MAYBE&#39;, 1);
/** Strict mode always applies */
define(&#39;GESHI_ALWAYS&#39;, 2);
 
// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define(&#39;GESHI_SEARCH&#39;, 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define(&#39;GESHI_REPLACE&#39;, 1);
/** The key of the regex array defining any modifiers to the regular expression */
define(&#39;GESHI_MODIFIERS&#39;, 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define(&#39;GESHI_BEFORE&#39;, 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define(&#39;GESHI_AFTER&#39;, 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp&#39;s html tag class */
define(&#39;GESHI_CLASS&#39;, 5);
 
/** Used in language files to mark comments */
define(&#39;GESHI_COMMENTS&#39;, 0);
 
// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define(&#39;GESHI_ERROR_NO_INPUT&#39;, 1);
/** The language specified does not exist */
define(&#39;GESHI_ERROR_NO_SUCH_LANG&#39;, 2);
/** GeSHi could not open a file for reading (generally a language file) */
define(&#39;GESHI_ERROR_FILE_NOT_READABLE&#39;, 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define(&#39;GESHI_ERROR_INVALID_HEADER_TYPE&#39;, 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define(&#39;GESHI_ERROR_INVALID_LINE_NUMBER_TYPE&#39;, 5);
/**#@-*/
</code></pre>
</div>
 
 
 
<div class="section">
<h3>PRE带有 class="ln-"</h3>
<p>PRE带有  class="ln-" 代码将会有从1开始的行号.</p>
<pre class="ln-"><code class="php">
/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define(&#39;GESHI_NEVER&#39;, 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define(&#39;GESHI_MAYBE&#39;, 1);
/** Strict mode always applies */
define(&#39;GESHI_ALWAYS&#39;, 2);
 
// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define(&#39;GESHI_SEARCH&#39;, 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define(&#39;GESHI_REPLACE&#39;, 1);
/** The key of the regex array defining any modifiers to the regular expression */
define(&#39;GESHI_MODIFIERS&#39;, 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define(&#39;GESHI_BEFORE&#39;, 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define(&#39;GESHI_AFTER&#39;, 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp&#39;s html tag class */
define(&#39;GESHI_CLASS&#39;, 5);
 
/** Used in language files to mark comments */
define(&#39;GESHI_COMMENTS&#39;, 0);
 
// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define(&#39;GESHI_ERROR_NO_INPUT&#39;, 1);
/** The language specified does not exist */
define(&#39;GESHI_ERROR_NO_SUCH_LANG&#39;, 2);
/** GeSHi could not open a file for reading (generally a language file) */
define(&#39;GESHI_ERROR_FILE_NOT_READABLE&#39;, 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define(&#39;GESHI_ERROR_INVALID_HEADER_TYPE&#39;, 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define(&#39;GESHI_ERROR_INVALID_LINE_NUMBER_TYPE&#39;, 5);
/**#@-*/
</code></pre>
</div>
 
 
 
<div class="section">
<h3>PRE带有 class="ln-172"</h3>
<p>PRE带有  class="ln-N" 代码将带有从指定数字N开始的行号</p>
<pre class="ln-172"><code class="php">
/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define(&#39;GESHI_NEVER&#39;, 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define(&#39;GESHI_MAYBE&#39;, 1);
/** Strict mode always applies */
define(&#39;GESHI_ALWAYS&#39;, 2);
 
// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define(&#39;GESHI_SEARCH&#39;, 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define(&#39;GESHI_REPLACE&#39;, 1);
/** The key of the regex array defining any modifiers to the regular expression */
define(&#39;GESHI_MODIFIERS&#39;, 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define(&#39;GESHI_BEFORE&#39;, 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define(&#39;GESHI_AFTER&#39;, 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp&#39;s html tag class */
define(&#39;GESHI_CLASS&#39;, 5);
 
/** Used in language files to mark comments */
define(&#39;GESHI_COMMENTS&#39;, 0);
 
// Error detection - use these to analyse faults
/** No sourcecode to highlight was specified
 * @deprecated
 */
define(&#39;GESHI_ERROR_NO_INPUT&#39;, 1);
/** The language specified does not exist */
define(&#39;GESHI_ERROR_NO_SUCH_LANG&#39;, 2);
/** GeSHi could not open a file for reading (generally a language file) */
define(&#39;GESHI_ERROR_FILE_NOT_READABLE&#39;, 3);
/** The header type passed to {@link GeSHi::set_header_type()} was invalid */
define(&#39;GESHI_ERROR_INVALID_HEADER_TYPE&#39;, 4);
/** The line number type passed to {@link GeSHi::enable_line_numbers()} was invalid */
define(&#39;GESHI_ERROR_INVALID_LINE_NUMBER_TYPE&#39;, 5);
/**#@-*/
</code></pre>
</div>
 
 
 
<div class="section">
<h3>PRE带有 class="ln-172-access-private"</h3>
<p>第一个PRE带有 class="ln-172-access-private" 代码会带有从制定行数开始编号的行号</p>
<pre class="ln-172-access-private">
<code class="php">
/**#@+
 *  @access private
 */
// When strict mode applies for a language
/** Strict mode never applies (this is the most common) */
define(&#39;GESHI_NEVER&#39;, 0);
/** Strict mode *might* apply, and can be enabled or
    disabled by {@link GeSHi::enable_strict_mode()} */
define(&#39;GESHI_MAYBE&#39;, 1);
/** Strict mode always applies */
define(&#39;GESHI_ALWAYS&#39;, 2);
 
</code></pre>
</div>
 
 
 
<div class="section">
<h3>PRE带有 class="ln-172-access-private"</h3>
<p>如何之前也有PER带有 class="ln-172-access-private",那么该段代码将接上个PRE的最大编号开始显示行号。</p>
<pre class="ln-172-access-private">
    <code class="php">
// Advanced regexp handling constants, used in language files
/** The key of the regex array defining what to search for */
define(&#39;GESHI_SEARCH&#39;, 0);
/** The key of the regex array defining what bracket group in a
    matched search to use as a replacement */
define(&#39;GESHI_REPLACE&#39;, 1);
/** The key of the regex array defining any modifiers to the regular expression */
define(&#39;GESHI_MODIFIERS&#39;, 2);
/** The key of the regex array defining what bracket group in a
    matched search to put before the replacement */
define(&#39;GESHI_BEFORE&#39;, 3);
/** The key of the regex array defining what bracket group in a
    matched search to put after the replacement */
define(&#39;GESHI_AFTER&#39;, 4);
/** The key of the regex array defining a custom keyword to use
    for this regexp&#39;s html tag class */
define(&#39;GESHI_CLASS&#39;, 5);
 
/** Used in language files to mark comments */
define(&#39;GESHI_COMMENTS&#39;, 0);
 
</code>
</pre>
</div>