Rover12421's Blog

The End.

Syntaxhighlighter 自己添加高亮JS

        syntaxhighlighter核心的高亮显示插件,看到很多插件用的他,还不错吧,就是速度不怎么样,而且支持高亮的代码不多。上次为了代码高亮用个这个内核的WordPress的syntaxhighlighter 插件,自己还给添加了两种高亮代码。下面来说下怎么自己添加。
1.在scripts目录下新建高亮语法js文件。下面是我写的2个语法高亮js文件:
syntaxhighlighter\scripts\shBrushDos.js

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
/**
 * SyntaxHighlighter
 * http://alexgorbatchev.com/
 *
 * Rover12421 Amend.
 * https://www.rover12421.com/
 *
 * SyntaxHighlighter is donationware. If you are using it, please donate.
 * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
 *
 * @version
 * 2.0.296 (March 01 2009)
 * shBrushDos 1.0.20090407
 *
 * @copyright
 * shBrushDos Copyright (C) 2009 Rover12421.
 *
 */
SyntaxHighlighter.brushes.Dos = function()
{
    var keywords =  'if else goto for in do call exit ' +
                    'not exist errorlevel defined equ neq lss leq gtr gep ' +
                    'shift cd dir echo setlocal endlocal set pause ' +
                    'prn nul lpt3 lpt2 lpt1 con com4 com3 com2 com1 aux ' ;
 
    this.regexList = [
        { regex: SyntaxHighlighter.regexLib.doubleQuotedString,     css: 'string' },        // strings
        { regex: SyntaxHighlighter.regexLib.singleQuotedString,     css: 'string' },        // strings
        { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi,             css: 'value' },         // numbers
        { regex: /%%\w+/g,                          css: 'variable' },          // variables
        { regex: /!\w+!|%\w+%/g,                    css: 'variable' },          // variables
        { regex: /[\-|\/]\w+/g,                     css: 'color1' },            // parameter
        { regex: new RegExp(this.getKeywords(keywords), 'gi'),      css: 'keyword' }        // Dos keyword      
        ];
 
    this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
};
 
SyntaxHighlighter.brushes.Dos.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Dos.aliases       = ['dos', 'bat', 'cmd'];

syntaxhighlighter\scripts\shBrushAsm.js

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
/**
 * SyntaxHighlighter
 * http://alexgorbatchev.com/
 *
 * Rover12421 Amend.
 * https://www.rover12421.com/
 *
 * SyntaxHighlighter is donationware. If you are using it, please donate.
 * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
 *
 * @version
 * 2.0.296 (March 01 2009)
 * shBrushAsm 1.0.20090407
 * 
 * @copyright
 * shBrushAsm Copyright (C) 2009 Rover12421.
 *
 */
 SyntaxHighlighter.brushes.Asm = function()
{
    // Copyright 2009 Rover12421
 
    var cpu =   'aaa aad aam aas adc add and call cbw clc cld cli cmc cmp ' +
                    'cmps cmpsb cmpsw cwd daa das dec div esc hlt idiv imul in inc ' +
                    'int into iret ja jae jb jbe jc jcxz je jg jge jl jle jmp ' +
                    'jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz ' +
                    'jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop ' +
                    'loope loopew loopne loopnew loopnz loopnzw loopw loopz loopzw mov ' +
                    'movs movsb movsw mul neg nop not or out pop popf push pushf ' +
                    'rcl rcr ret retf retn rol ror sahf sal sar sbb scas scasb scasw ' +
                    'shl shr stc std sti stos stosb stosw sub test wait xchg xlat ' +
                    'xlatb xor bound enter ins insb insw leave outs outsb outsw popa pusha pushw ' +
                    'arpl lar lsl sgdt sidt sldt smsw str verr verw clts lgdt lidt lldt lmsw ltr ' +
                    'bsf bsr bt btc btr bts cdq cmpsd cwde insd iretd iretdf iretf ' +
                    'jecxz lfs lgs lodsd loopd looped loopned loopnzd loopzd lss movsd ' +
                    'movsx movzx outsd popad popfd pushad pushd pushfd scasd seta setae ' +
                    'setb setbe setc sete setg setge setl setle setna setnae setnb setnbe ' +
                    'setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp ' +
                    'setpe setpo sets setz shld shrd stosd bswap cmpxchg invd invlpg wbinvd xadd lock ' +
                    'rep repe repne repnz repz';
 
    var fpu =   'f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp ' +
                    'fdisi fdiv fdivp fdivr fdivrp feni ffree fiadd ficom ficomp fidiv ' +
                    'fidivr fild fimul fincstp finit fist fistp fisub fisubr fld fld1 ' +
                    'fldcw fldenv fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul ' +
                    'fmulp fnclex fndisi fneni fninit fnop fnsave fnsavew fnstcw fnstenv ' +
                    'fnstenvw fnstsw fpatan fprem fptan frndint frstor frstorw fsave ' +
                    'fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub fsubp ' +
                    'fsubr fsubrp ftst fwait fxam fxch fxtract fyl2x fyl2xp1 ' +
                    'fsetpm fcos fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin fsincos ' +
                    'fstenvd fucom fucomp fucompp';
 
    var registers = 'ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cs cx dh di dl ' +
                    'dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp ebx ecx edi edx ' +
                    'es esi esp fs gs si sp ss st tr3 tr4 tr5 tr6 tr7 ' +
                    'ah bh ch dh';
 
    var directive = '186 286 286c 286p 287 386 386c 386p 387 486 486p ' +
                    '8086 8087 alpha break code const continue cref data ' +
                    'dosseg else elseif endif endw err err1 err2 errb ' +
                    'errdef errdif errdifi erre erridn erridni errnb errndef ' +
                    'errnz exit fardata if lall lfcond list listall ' +
                    'listif listmacro listmacroall  model no87 nocref nolist ' +
                    'nolistif nolistmacro repeat sall seq sfcond stack ' +
                    'startup tfcond type until untilcxz while xall xcref ' +
                    'xlist alias align assume catstr comm comment db dd df dosseg dq ' +
                    'dt dup dw echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif ' +
                    'elseifdifi elseife elseifidn elseifidni elseifnb elseifndef end ' +
                    'endif endm endp ends eq  equ even exitm extern externdef extrn for ' +
                    'forc ge goto group high highword if if1 if2 ifb ifdef ifdif ' +
                    'ifdifi ife  ifidn ifidni ifnb ifndef include includelib instr invoke ' +
                    'irp irpc label le length lengthof local low lowword lroffset ' +
                    'macro mask mod msfloat name ne offset opattr option org ' +
                    'page popcontext proc proto ptr public purge pushcontext record ' +
                    'repeat rept seg segment short size sizeof sizestr struc struct ' +
                    'substr subtitle subttl textequ this title type typedef union while width';
 
    var operands =  'addr basic byte c dword ' +
                    'far far16 fortran fword near near16 pascal qword ' +
                    'real4  real8 real10 sbyte sdword sign? stdcall sword syscall tbyte ' +
                    'vararg word flat near32 far32 ' +
                    'abs all assumes at casemap common compact ' +
                    'cpu dotname emulator epilogue error export expr16 expr32 farstack flat ' +
                    'forceframe huge language large listing ljmp loadds m510 medium memory ' +
                    'nearstack nodotname noemulator nokeyword noljmp nom510 none nonunique ' +
                    'nooldmacros nooldstructs noreadonly noscoped nosignextend nothing ' +
                    'notpublic oldmacros oldstructs os_dos para private prologue radix ' +
                    'readonly req scoped setif2 smallstack tiny use16 use32 uses';
 
    this.regexList = [
        { regex: /;(.*)$/gm,                        css: 'comments' },  // one line and multiline comments
        { regex: SyntaxHighlighter.regexLib.doubleQuotedString,     css: 'string' },            // strings
        { regex: SyntaxHighlighter.regexLib.singleQuotedString,     css: 'string' },            // strings
        { regex: new RegExp(this.getKeywords(cpu), 'gmi'),      css: 'keyword' },   //CPU
        { regex: new RegExp(this.getKeywords(fpu), 'gmi'),      css: 'functions bold' },    //FPU
        { regex: new RegExp(this.getKeywords(registers), 'gmi'),    css: 'color2' },    //registers 
        { regex: new RegExp(this.getKeywords(directive), 'gmi'),        css: 'color1' },    //directive
        { regex: /data\?|fardata\?|\%out|\.model|\.stack|\.code|\.data/gi,  css: 'color1' },    //directive addition
        { regex: new RegExp(this.getKeywords(operands), 'gmi'),     css: 'value' },     //operands
        { regex: /@b|@f|carry\?|overflow\?|parity\?|zero\?/gi,      css: 'value' }      //operands addition
        ];
};
 
SyntaxHighlighter.brushes.Asm.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Asm.aliases   = ['asm', 'ash'];

SyntaxHighlighter.brushes.Asm = function()
这句是定义处理函数,中间是具体的处理内容,看自己会不会了。其实我也不会,照原来的该就行。一般就是注释,关键词,函数这些,其他的就要自己去想了。
SyntaxHighlighter.brushes.Asm.aliases = [‘asm’, ‘ash’];
提交的参数设置,这句是,lang为asm,ash都是有着个js来处理。
2.修改syntaxhighlighter.php文件
这是PHP版的,如果是其他语言使用的这个核心文件,修改相应的配置文件就行了。
在着个文件中添加下面的语句,位置很好找,参照里面的格式写,这是加载需要的js文件

1
2
wp_register_script( 'syntaxhighlighter-brush-dos',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushDos.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-asm',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushAsm.js'),        array('syntaxhighlighter-core'), $this->agshver );

再在下面一点添加格式,在这句下面$this->brushes = apply_filters。仔细看这文件就知道,很有规律的。下里面添加下面几句。

1
2
3
4
5
'dos'        => 'dos',
'bat'        => 'dos',
'cmd'        => 'dos',
'asm'        => 'asm',
'ash'        => 'asm',

注意一点,只有最后一行没有",“号。
下面把我修改好的syntaxhighlighter.php贴下吧
syntaxhighlighter.php

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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
<?php /*
 
**************************************************************************
 
Plugin Name:  R's SyntaxHighlighter
Plugin URI:   https://www.rover12421.com
Version:      1.2.0.20090404
Description:  Easily post syntax-highlighted code to your site without having to modify the code at all. Uses Alex Gorbatchev's <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter">SyntaxHighlighter</a> and code by <a href="http://automattic.com/">Automattic</a>.Supports C++, C#, CSS, Delphi, Java, JavaScript, PHP, Python, Ruby, SQL, VB, XML, and HTML.
Author:       Rover12421
Author URI:   https://www.rover12421.com/
 
**************************************************************************
 
Thanks to:
 
* Alex Gorbatchev for writing such an awesome Javascript-powered synatax
  highlighter script
 
* Automattic for writing the TinyMCE plugin and azaozz for helping me
  expand it's capabilities for use in this plugin.
 
**************************************************************************/
 
class SyntaxHighlighter {
    // All of these variables are private. Filters are provided for things that can be modified.
    var $pluginver       = '2.0.0';   // Plugin version
    var $agshver         = '2.0.296'; // Alex Gorbatchev's SyntaxHighlighter version
    var $settings        = array();   // Contains the user's settings
    var $defaultsettings = array();   // Contains the default settings
    var $brushes         = array();   // Array of aliases => brushes
    var $themes          = array();   // Array of themes
    var $usedbrushes     = array();   // Stores used brushes so we know what to output
    var $encoded         = false;     // Used to mark that a character encode took place
 
    // Initalize the plugin by registering the hooks
    function __construct() {
        // Check WordPress version
        if ( !function_exists( 'plugins_url' ) ) return;
 
        // Load localization domain
        load_plugin_textdomain( 'rs-syntaxhighlighter', FALSE, '/syntaxhighlighter/localization' );
 
        // Register brush scripts
        wp_register_script( 'syntaxhighlighter-core',             plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js'),            array(),                         $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-bash',       plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushBash.js'),       array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-csharp',     plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCSharp.js'),     array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-cpp',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCpp.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-css',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCss.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-delphi',     plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushDelphi.js'),     array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-diff',       plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushDiff.js'),       array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-groovy',     plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushGroovy.js'),     array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-jscript',    plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJScript.js'),    array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-java',       plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js'),       array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-perl',       plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPerl.js'),       array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-php',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPhp.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-plain',      plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPlain.js'),      array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-python',     plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPython.js'),     array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-ruby',       plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushRuby.js'),       array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-scala',      plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushScala.js'),      array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-sql',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushSql.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-vb',         plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushVb.js'),         array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-xml',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushXml.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-dos',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushDos.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-asm',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushAsm.js'),        array('syntaxhighlighter-core'), $this->agshver );
        wp_register_script( 'syntaxhighlighter-brush-ini',        plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/shBrushIni.js'),        array('syntaxhighlighter-core'), $this->agshver );
 
        // Register theme stylesheets
        wp_register_style(  'syntaxhighlighter-core',             plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shCore.css'),            array(),                         $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-default',    plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeDefault.css'),    array('syntaxhighlighter-core'), $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-django',     plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeDjango.css'),     array('syntaxhighlighter-core'), $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-emacs',      plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeEmacs.css'),      array('syntaxhighlighter-core'), $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-fadetogrey', plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeFadeToGrey.css'), array('syntaxhighlighter-core'), $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-midnight',   plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeMidnight.css'),   array('syntaxhighlighter-core'), $this->agshver );
        wp_register_style(  'syntaxhighlighter-theme-rdark',      plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/styles/shThemeRDark.css'),      array('syntaxhighlighter-core'), $this->agshver );
 
        // Register hooks
        add_action( 'admin_menu',                   array(&$this, 'register_settings_page') );
        add_action( 'admin_post_syntaxhighlighter', array(&$this, 'save_settings') );
        add_action( 'admin_head',                   array(&$this, 'admin_head') );
        add_filter( 'the_content',                  array(&$this, 'parse_shortcodes'),          9 );
        add_filter( 'widget_text',                  array(&$this, 'parse_shortcodes'),          9 );
        add_action( 'wp_footer',                    array(&$this, 'maybe_output_scripts'),      15 );
        add_filter( 'mce_external_plugins',         array(&$this, 'add_tinymce_plugin') );
        add_filter( 'tiny_mce_version',             array(&$this, 'break_tinymce_cache') );
        add_filter( 'the_editor_content',           array(&$this, 'decode_shortcode_contents'), 1 );
        add_filter( 'content_save_pre',             array(&$this, 'encode_shortcode_contents'), 1 );
        add_filter( 'save_post',                    array(&$this, 'mark_as_encoded'),           10, 2 );
 
        // Create list of brush aliases and map them to their real brushes
        $this->brushes = apply_filters( 'syntaxhighlighter_brushes', array(
            'asm'        => 'asm',
            'ash'        => 'asm',
            'bash'       => 'bash',
            'shell'      => 'bash',
            'c-sharp'    => 'csharp',
            'csharp'     => 'csharp',
            'cpp'        => 'cpp',
            'c'          => 'cpp',
            'css'        => 'css',
            'delphi'     => 'delphi',
            'pas'        => 'delphi',
            'pascal'     => 'delphi',
            'diff'       => 'diff',
            'patch'      => 'diff',
            'dos'        => 'dos',
            'bat'        => 'dos',
            'cmd'        => 'dos',
            'ini'        => 'ini',
            'groovy'     => 'groovy',
            'js'         => 'jscript',
            'jscript'    => 'jscript',
            'javascript' => 'jscript',
            'java'       => 'java',
            'perl'       => 'perl',
            'pl'         => 'perl',
            'php'        => 'php',
            'plain'      => 'plain',
            'text'       => 'plain',
            'py'         => 'python',
            'python'     => 'python',
            'rails'      => 'ruby',
            'ror'        => 'ruby',
            'ruby'       => 'ruby',
            'scala'      => 'scala',
            'sql'        => 'sql',
            'vb'         => 'vb',
            'vbnet'      => 'vb',
            'xml'        => 'xml',
            'xhtml'      => 'xml',
            'xslt'       => 'xml',
            'html'       => 'xml',
            'xhtml'      => 'xml',
        ) );
 
        // Create list of themes and their human readable names
        // Plugins can add to this list as long as they also register a style with the handle "syntaxhighlighter-theme-THEMENAMEHERE"
        $this->themes = apply_filters( 'syntaxhighlighter_themes', array(
            'default'    => __( 'Default',      'syntaxhighlighter' ),
            'django'     => __( 'Django',       'syntaxhighlighter' ),
            'emacs'      => __( 'Emacs',        'syntaxhighlighter' ),
            'fadetogrey' => __( 'Fade to Grey', 'syntaxhighlighter' ),
            'midnight'   => __( 'Midnight',     'syntaxhighlighter' ),
            'rdark'      => __( 'RDark',        'syntaxhighlighter' ),
            'none'       => __( '[None]',       'syntaxhighlighter' ),
        ) );
 
        // Create array of default settings (you can use the filter to modify these)
        $this->defaultsettings = apply_filters( 'syntaxhighlighter_defaultsettings', array(
            'theme'      => 'default',
            'autolinks'  => 1,
            'classname'  => '',
            'collapse'   => ,
            'firstline'  => 1,
            'fontsize'   => 100,
            'gutter'     => 1,
            'light'      => ,
            'ruler'      => ,
            'smarttabs'  => 1,
            'tabsize'    => 4,
            'toolbar'    => 1,
        ) );
 
        // Setup the settings by using the default as a base and then adding in any changed values
        // This allows settings arrays from old versions to be used even though they are missing values
        $usersettings = (array) get_option('syntaxhighlighter_settings');
        $this->settings = $this->defaultsettings;
        if ( $usersettings !== $this->defaultsettings ) {
            foreach ( (array) $usersettings as $key1 => $value1 ) {
                if ( is_array($value1) ) {
                    foreach ( $value1 as $key2 => $value2 ) {
                        $this->settings[$key1][$key2] = $value2;
                    }
                } else {
                    $this->settings[$key1] = $value1;
                }
            }
        }
 
        // Load the user's selected theme
        if ( 'none' == $this->settings['theme'] )
            wp_enqueue_style( 'syntaxhighlighter-core' );
        else {
            $theme = ( !empty($this->themes[$this->settings['theme']]) ) ? strtolower($this->settings['theme']) : $this->defaultsettings['theme'];
            wp_enqueue_style( 'syntaxhighlighter-theme-' . $theme );
        }
    }
 
 
    // Register the settings page
    function register_settings_page() {
        add_options_page( __('SyntaxHighlighter Settings', 'syntaxhighlighter'), __('SyntaxHighlighter', 'syntaxhighlighter'), 'manage_options', 'syntaxhighlighter', array(&$this, 'settings_page') );
    }
 
 
    // Add the custom TinyMCE plugin which wraps plugin shortcodes in <pre> in TinyMCE
    function add_tinymce_plugin( $plugins ) {
        $plugins['syntaxhighlighter'] = plugins_url('/rs-syntaxhighlighter/syntaxhighlighter_mce.js');
        return $plugins;
    }
 
 
    // Break the TinyMCE cache
    function break_tinymce_cache( $version ) {
        return $version . '-syntaxhighlighter' . $this->pluginver;
    }
 
 
    // Output list of shortcode tags for the TinyMCE plugin as well as some CSS for the settings page
    function admin_head() {
        $tags = array();
        $tags[] = 'sourcecode';
        $tags[] = 'source';
        $tags[] = 'code';
        $tags[] = 'lang';
        $tags[] = 'language';
 
        foreach ( $this->brushes as $tag => $brush )
            $tags[] = preg_quote( $tag );
 
        echo "<script type='text/javascript'>\n";
        echo "   var syntaxHLcodes = '" . implode( '|', $tags ) . "';\n";
        echo "</script>\n";
 
        echo "<style type='text/css'>.bulletlist li { list-style-type: disc; margin-left: 25px; }</style>\n";
    }
 
 
    // A filter function that runs do_shortcode() but only with this plugin's shortcodes
    function shortcode_hack( $content, $callback ) {
        global $shortcode_tags;
 
        // Backup current registered shortcodes and clear them all out
        $orig_shortcode_tags = $shortcode_tags;
        remove_all_shortcodes();
 
        // Register all of this plugin's shortcodes
        add_shortcode( 'sourcecode', $callback );
        add_shortcode( 'source', $callback );
        add_shortcode( 'code', $callback );
        add_shortcode( 'lang', $callback );
        add_shortcode( 'language', $callback );
        foreach ( $this->brushes as $shortcode => $brush )
            add_shortcode( $shortcode, $callback );
 
        // Do the shortcodes (only this plugins's are registered)
        $content = do_shortcode( $content );
 
        // Put the original shortcodes back
        $shortcode_tags = $orig_shortcode_tags;
 
        return $content;
    }
 
 
    // The main filter for the post contents. The regular shortcode filter can't be used as it's post-wpautop().
    function parse_shortcodes( $content ) {
        return $this->shortcode_hack( $content, array(&$this, 'shortcode_callback') );
    }
 
 
    // HTML entity encode the contents of shortcodes. Note this handles $_POST-sourced data, so it has to deal with slashes
    function encode_shortcode_contents( $content ) {
        $this->encoded = true;
        return addslashes( $this->shortcode_hack( stripslashes( $content ), array(&$this, 'encode_shortcode_contents_callback') ) );
    }
 
 
    // HTML entity decode the contents of shortcodes
    function decode_shortcode_contents( $content ) {
        // If TinyMCE is enabled and set to be displayed first, leave it encoded
        if ( user_can_richedit() && 'html' != wp_default_editor() )
            return $content;
 
        return $this->shortcode_hack( $content, array(&$this, 'decode_shortcode_contents_callback') );
    }
 
 
    // The callback function for SyntaxHighlighter::encode_shortcode_contents()
    function encode_shortcode_contents_callback( $atts, $code = '', $tag = false ) {
        return '[' . $tag . $this->atts2string( $atts ) . ']' . htmlspecialchars( $code ) . "[/$tag]";
    }
 
 
    // The callback function for SyntaxHighlighter::decode_shortcode_contents()
    // Shortcode attribute values need to not be quoted with TinyMCE disabled for some reason (weird bug)
    function decode_shortcode_contents_callback( $atts, $code = '', $tag = false ) {
        $quotes = ( user_can_richedit() ) ? true : false;
        return '[' . $tag . $this->atts2string( $atts, $quotes ) . ']' . htmlspecialchars_decode( $code ) . "[/$tag]";
    }
 
 
    // Adds a post meta saying that HTML entities are encoded (for backwards compatibility)
    function mark_as_encoded( $post_ID, $post ) {
        if ( false == $this->encoded || 'revision' == $post->post_type )
            return;
 
        add_post_meta( $post_ID, 'syntaxhighlighter_encoded', true, true );
    }
 
 
    // Transforms an attributes array into a 'key="value"' format (i.e. reverses the process)
    function atts2string( $atts, $quotes = true ) {
        if ( empty($atts) )
            return '';
 
        $atts = $this->attributefix( $atts );
 
        // Re-map [code="php"] style tags
        if ( isset($atts[]) ) {
            if ( empty($atts['language']) )
                $atts['language'] = $atts[];
 
            unset($atts[]);
        }
 
        $strings = array();
        foreach ( $atts as $key => $value )
            $strings[] = ( $quotes ) ? $key . '="' . attribute_escape( $value ) . '"' : $key . '=' . attribute_escape( $value );
 
        return ' ' . implode( ' ', $strings );
    }
 
 
    // Simple function for escaping just single quotes (the original js_escape() escapes more than we need)
    function js_escape_singlequotes( $string ) {
        return str_replace( "'", "\'", $string );
    }
 
 
    // Output any needed scripts. This is meant for the footer.
    function maybe_output_scripts() {
        if ( empty($this->usedbrushes) )
            return;
 
        $scripts = array();
        foreach ( $this->usedbrushes as $brush => $unused )
            $scripts[] = 'syntaxhighlighter-brush-' . strtolower( $brush );
 
        wp_print_scripts( $scripts );
 
        echo "<script type='text/javascript'>\n";
        echo "   SyntaxHighlighter.config.clipboardSwf = '" . js_escape( plugins_url('/rs-syntaxhighlighter/syntaxhighlighter/scripts/clipboard.swf') ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.expandSource = '" . $this->js_escape_singlequotes( __( 'expand source', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.viewSource = '" . $this->js_escape_singlequotes( __( 'view source', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.copyToClipboard = '" . $this->js_escape_singlequotes( __( 'copy to clipboard', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.copyToClipboardConfirmation = '" . $this->js_escape_singlequotes( __( 'The code is in your clipboard now', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.print = '" . $this->js_escape_singlequotes( __( 'print', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.help = '" . $this->js_escape_singlequotes( __( '?', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.alert = '" . $this->js_escape_singlequotes( __( 'SyntaxHighlighter\n\n', 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.noBrush = '" . $this->js_escape_singlequotes( __( "Can't find brush for: ", 'syntaxhighlighter' ) ) . "';\n";
        echo "   SyntaxHighlighter.config.strings.brushNotHtmlScript = '" . $this->js_escape_singlequotes( __( "Brush wasn't configured for html-script option: ", 'syntaxhighlighter' ) ) . "';\n";
 
        if ( 1 != $this->settings['autolinks'] )
            echo "   SyntaxHighlighter.defaults['auto-links'] = false;\n";
 
        if ( !empty($this->settings['classname']) )
            echo "   SyntaxHighlighter.defaults['class-name'] = '" . $this->js_escape_singlequotes( $this->settings['classname'] ) . "';\n";
 
        if ( 1 == $this->settings['collapse'] )
            echo "   SyntaxHighlighter.defaults['collapse'] = true;\n";
 
        if ( 1 != $this->settings['firstline'] )
            echo "   SyntaxHighlighter.defaults['first-line'] = " . $this->settings['firstline'] . ";\n";
 
        if ( 100 != $this->settings['fontsize'] )
            echo "   SyntaxHighlighter.defaults['font-size'] = '" . $this->settings['fontsize'] . "%';\n";
 
        if ( 1 != $this->settings['gutter'] )
            echo "   SyntaxHighlighter.defaults['gutter'] = false;\n";
 
        if ( 1 == $this->settings['light'] )
            echo "   SyntaxHighlighter.defaults['light'] = true;\n";
 
        if ( 1 == $this->settings['ruler'] )
            echo "   SyntaxHighlighter.defaults['ruler'] = true;\n";
 
        if ( 1 != $this->settings['smarttabs'] )
            echo "   SyntaxHighlighter.defaults['smart-tabs'] = false;\n";
 
        if ( 4 != $this->settings['tabsize'] )
            echo "   SyntaxHighlighter.defaults['tab-size'] = " . $this->settings['tabsize'] . ";\n";
 
        if ( 1 != $this->settings['toolbar'] )
            echo "   SyntaxHighlighter.defaults['toolbar'] = false;\n";
 
        echo "   SyntaxHighlighter.all();\n";
        echo "</script>\n";
    }
 
 
    // No-name attribute fixing
    function attributefix( $atts = array() ) {
        if ( empty($atts[]) )
            return $atts;
 
        // Quoted value
        if (  !== preg_match( '#=("|\')(.*?)\1#', $atts[], $match ) )
            $atts[] = $match[2];
 
        // Unquoted value
        elseif ( '=' == substr( $atts[], , 1 ) )
            $atts[] = substr( $atts[], 1 );
 
        return $atts;
    }
 
 
    // Shortcode handler for transforming the shortcodes to their final <pre>'s
    function shortcode_callback( $atts, $code = '', $tag = false ) {
        global $post;
 
        if ( false === $tag || empty($code) )
            return $code;
 
        // Error fixing for [tag="language"]
        if ( isset($atts[]) ) {
            $atts = $this->attributefix( $atts );
            $atts['language'] = $atts[];
            unset($atts[]);
        }
 
        // Default out all of the available parameters to "false" (easy way to check if they're set or not)
        // Note this isn't the same as if the user passes the string "false" to the shortcode
        $atts = apply_filters( 'syntaxhighlighter_shortcodeatts', shortcode_atts( array(
            'language'   => false,
            'lang'       => false,
            'autolinks'  => false,
            'classname'  => false,
            'collapse'   => false,
            'firstline'  => false,
            'gutter'     => false,
            'highlight'  => false,
            'htmlscript' => false,
            'light'      => false,
            'ruler'      => false,
            'smarttabs'  => false,
            'tabsize'    => false,
            'toolbar'    => false,
        ), $atts ) );
 
        // Check for language shortcode tag such as [php]code[/php]
        if ( isset($this->brushes[$tag]) ) {
            $lang = $tag;
        }
 
        // If a valid tag is not used, it must be sourcecode/source/code
        else {
            $atts = $this->attributefix( $atts );
 
            // Check for the "language" attribute
            if ( false !== $atts['language'] )
                $lang = $atts['language'];
 
            // Check for the "lang" attribute
            elseif ( false !== $atts['lang'] )
                $lang = $atts['lang'];
 
            // Default to plain text
            else
                $lang = 'text';
 
            // Validate passed attribute
            if ( !isset($this->brushes[$lang]) )
                return $code;
        }
 
        // Ensure lowercase
        $lang = strtolower( $lang );
 
        // Register this brush as used so it's script will be outputted
        $this->usedbrushes[$this->brushes[$lang]] = true;
 
        $params = array();
        $params[] = "brush: $lang;";
 
        // Fix bug that prevents collapse from working if the toolbar is off
        if ( 1 == $atts['collapse'] || 'true' == $atts['collapse'] ) {
            $atts['toolbar'] = 'true';
            $atts['light'] = 'false';
        }
 
        // Enable "htmlscript" for certain brushes
        //if ( false === $atts['html-script'] && in_array( $lang, apply_filters( 'syntaxhighlighter_htmlscriptbrushes', array( 'php' ) ) ) )
        //    $atts['html-script'] = 'true';
 
        foreach ( $atts as $key => $value ) {
            if ( false === $value || in_array( $key, array( 'language', 'lang' ) ) )
                continue;
 
            // Parameter renaming (the shortcode API doesn't like parameter names with dashes)
            $rename_map = array(
                'autolinks'  => 'auto-links',
                'classname'  => 'class-name',
                'firstline'  => 'first-line',
                'htmlscript' => 'html-script',
                'smarttabs'  => 'smart-tabs',
                'tabsize'    => 'tab-size',
            );
            if ( !empty($rename_map[$key]) )
                $key = $rename_map[$key];
 
            // If "html-script", then include the XML brush as it's needed
            if ( $key == 'html-script' && ( 'true' == $value || 1 == $value ) )
                $this->usedbrushes['xml'] = true;
 
            if ( 'highlight' == $key )
                $params[] = "$key: [$value];";
            else
                $params[] = "$key: $value;";
        }
 
        $content  = '<pre class="' . attribute_escape( implode( ' ', $params ) ) . '">';
        $content .= ( get_post_meta( $post->ID, 'syntaxhighlighter_encoded', true ) ) ? $code : htmlspecialchars( $code );
        $content .= '</ pre>';
 
        return $content;
    }
 
 
    // Settings page
    function settings_page() {
        if ( !empty($_GET['defaults']) ) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Settings reset to defaults.', 'syntaxhighlighter'); ?></strong></p></div>
<?php endif; ?>
 
<script type="text/javascript">
// <![CDATA[
    jQuery(document).ready(function() {
        // Confirm pressing of the "Reset to Defaults" button
        jQuery("#syntaxhighlighter-defaults").click(function(){
            var areyousure = confirm("<?php echo js_escape( __('Are you sure you want to reset your settings to the defaults?', 'syntaxhighlighter') ); ?>");
            if ( true != areyousure ) return false;
        });
    });
// ]]>
</script>
 
<div class="wrap">
<?php if ( function_exists('screen_icon') ) screen_icon(); ?>
    <h2><?php _e( 'SyntaxHighlighter Settings', 'syntaxhighlighter' ); ?></h2>
 
    <form method="post" action="admin-post.php">
 
    <?php wp_nonce_field('syntaxhighlighter'); ?>
 
    <input type="hidden" name="action" value="syntaxhighlighter" />
 
    <table class="form-table">
        <tr valign="top">
            <th scope="row"><label for="syntaxhighlighter-theme"><?php _e('Color Theme', 'syntaxhighlighter'); ?></label></th>
            <td>
                <select name="syntaxhighlighter-theme" id="syntaxhighlighter-theme" class="postform">
<?php
                    foreach ( $this->themes as $theme => $name ) {
                        echo '                   <option value="' . attribute_escape($theme) . '"';
                        selected( $this->settings['theme'], $theme );
                        echo '>' . htmlspecialchars($name) . "</option>\n";
                    }
?>
                </select>
            </td>
        </tr>
    </table>
 
    <h3><?php _e('Defaults', 'syntaxhighlighter'); ?></h3>
 
    <p><?php _e('All of the settings below can also be configured on a per-code box basis.', 'syntaxhighlighter'); ?></p>
 
    <table class="form-table">
        <tr valign="top">
            <th scope="row"><?php _e('Miscellaneous', 'syntaxhighlighter'); ?></th>
            <td>
                <fieldset>
                    <legend class="hidden"><?php _e('Miscellaneous', 'syntaxhighlighter'); ?></legend>
 
                    <label for="syntaxhighlighter-gutter"><input name="syntaxhighlighter-gutter" type="checkbox" id="syntaxhighlighter-gutter" value="1" <?php checked( $this->settings['gutter'], 1 ); ?> /> <?php _e('Display line numbers', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-toolbar"><input name="syntaxhighlighter-toolbar" type="checkbox" id="syntaxhighlighter-toolbar" value="1" <?php checked( $this->settings['toolbar'], 1 ); ?> /> <?php _e('Display the toolbar', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-autolinks"><input name="syntaxhighlighter-autolinks" type="checkbox" id="syntaxhighlighter-autolinks" value="1" <?php checked( $this->settings['autolinks'], 1 ); ?> /> <?php _e('Automatically make URLs clickable', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-collapse"><input name="syntaxhighlighter-collapse" type="checkbox" id="syntaxhighlighter-collapse" value="1" <?php checked( $this->settings['collapse'], 1 ); ?> /> <?php _e('Collapse code boxes', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-ruler"><input name="syntaxhighlighter-ruler" type="checkbox" id="syntaxhighlighter-ruler" value="1" <?php checked( $this->settings['ruler'], 1 ); ?> /> <?php _e('Show a ruler column along the top of the code box', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-light"><input name="syntaxhighlighter-light" type="checkbox" id="syntaxhighlighter-light" value="1" <?php checked( $this->settings['light'], 1 ); ?> /> <?php _e('Use the light display mode, best for single lines of code', 'syntaxhighlighter'); ?></label><br />
                    <label for="syntaxhighlighter-smarttabs"><input name="syntaxhighlighter-smarttabs" type="checkbox" id="syntaxhighlighter-smarttabs" value="1" <?php checked( $this->settings['smarttabs'], 1 ); ?> /> <?php _e('Use smart tabs allowing tabs being used for alignment', 'syntaxhighlighter'); ?></label>
                </fieldset>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><label for="syntaxhighlighter-classname"><?php _e('Additional CSS Class(es)', 'syntaxhighlighter'); ?></label></th>
            <td><input name="syntaxhighlighter-classname" type="text" id="syntaxhighlighter-classname" value="<?php echo attribute_escape( $this->settings['classname'] ); ?>" class="regular-text" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><label for="syntaxhighlighter-firstline"><?php _e('Starting Line Number', 'syntaxhighlighter'); ?></label></th>
            <td><input name="syntaxhighlighter-firstline" type="text" id="syntaxhighlighter-firstline" value="<?php echo attribute_escape( $this->settings['firstline'] ); ?>" class="small-text" /></td>
        </tr>
        <tr valign="top" style="display:none">
            <th scope="row">
                <label for="syntaxhighlighter-fontsize"><?php _e('Font Size (Percentage)', 'syntaxhighlighter'); ?></label>
                <br /><strong>THIS CURRENTLY DOESN'T WORK</strong>
            </th>
            <td><input name="syntaxhighlighter-fontsize" type="text" id="syntaxhighlighter-fontsize" value="<?php echo attribute_escape( $this->settings['fontsize'] ); ?>" class="small-text" />%</td>
        </tr>
        <tr valign="top">
            <th scope="row"><label for="syntaxhighlighter-tabsize"><?php _e('Tab Size', 'syntaxhighlighter'); ?></label></th>
            <td><input name="syntaxhighlighter-tabsize" type="text" id="syntaxhighlighter-tabsize" value="<?php echo attribute_escape( $this->settings['tabsize'] ); ?>" class="small-text" /></td>
        </tr>
    </table>
 
    <p class="submit">
        <input type="submit" name="syntaxhighlighter-submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
        <input type="submit" name="syntaxhighlighter-defaults" id="syntaxhighlighter-defaults" class="button-primary" value="<?php _e('Reset to Defaults', 'syntaxhighlighter') ?>" />
    </p>
 
    </form>
 
    <h3><?php _e('Preview', 'syntaxhighlighter'); ?></h3>
 
    <p><?php _e('Click &quot;Save Changes&quot; to update this preview.', 'syntaxhighlighter'); ?>
 
    <?php
 
        global $post;
 
        $post->ID = 0;
 
        $democode = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>PHP Code Example</title>
</head>
<body>
    <h1>PHP Code Example</h1>
 
    <p><?php echo \'Hello World!\'; ?></p>
 
    <p>This line is highlighted.</p>
 
    <div class="foobar">
        This    is  an
        example of  smart
        tabs.
    </div>
 
    <p><a href="http://wordpress.org/">WordPress</a></p>
</body>
</html>';
 
        echo $this->parse_shortcodes( '[php htmlscript="true" highlight="12"]' . $democode . '[/php]' );
 
?>
 
    <h3 style="margin-top:30px"><?php _e('Shortcode Parameters', 'syntaxhighlighter'); ?></h3>
 
    <p><?php printf( __('These are the parameters you can pass to the shortcode and what they do. For the booleans (i.e. on/off), pass %1$s/%2$s or %3$s/%4$s.', 'syntaxhighlighter'), '<code>true</code>', '<code>1</code>', '<code>false</code>', '<code>0</code>' ); ?></p>
 
    <ul class="bulletlist">
        <li><?php printf( __('%1$s or %2$s — The language syntax to highlight with. You can alternately just use that as the tag, such as <code>[php]code[/php]</code>. <a href="%3$s">Click here</a> for a list of valid tags (under "aliases").', 'syntaxhighlighter'), '<code>lang</code>', '<code>language</code>', 'http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes' ); ?></li>
        <li><?php printf( __('%s — Toggle automatic URL linking.', 'syntaxhighlighter'), '<code>autolinks</code>' ); ?></li>
        <li><?php printf( __('%s — Add an additional CSS class to the code box.', 'syntaxhighlighter'), '<code>classname</code>' ); ?></li>
        <li><?php printf( __('%s — Toggle collapsing the code box by default, requiring a click to expand it. Good for large code posts.', 'syntaxhighlighter'), '<code>collapse</code>' ); ?></li>
        <li><?php printf( __('%s — An interger specifying what number the first line should be (for the line numbering).', 'syntaxhighlighter'), '<code>firstline</code>' ); ?></li>
        <li><?php printf( __('%s — Toggle the left-side line numbering.', 'syntaxhighlighter'), '<code>gutter</code>' ); ?></li>
        <li><?php printf( __('%s — A comma-sperated list of line numbers to highlight.', 'syntaxhighlighter'), '<code>highlight</code>' ); ?></li>
        <li><?php printf( __("%s — Toggle highlighting any extra HTML/XML. Good for when you're mixing HTML/XML with another language, such as having PHP inside an HTML web page. The above preview has it enabled for example.", 'syntaxhighlighter'), '<code>htmlscript</code>' ); ?></li>
        <li><?php printf( __("%s — Toggle light mode which disables the gutter, toolbar, and ruler all at once.", 'syntaxhighlighter'), '<code>light</code>' ); ?></li>
        <li><?php printf( __("%s — Toggle the column ruler at the top of the code box.", 'syntaxhighlighter'), '<code>ruler</code>' ); ?></li>
        <li><?php printf( __("%s — Toggle the toolbar containing the helpful buttons.", 'syntaxhighlighter'), '<code>toolbar</code>' ); ?></li>
    </ul>
 
    <p><?php _e('Some example shortcodes:', 'syntaxhighlighter'); ?></p>
 
    <ul class="bulletlist">
        <li><code>[php]<?php _e('your code here', 'syntaxhighlighter'); ?>[/php]</code></li>
        <li><code>[css autolinks=&quot;false&quot; classname=&quot;myclass&quot; collapse=&quot;false&quot; firstline=&quot;1&quot; gutter=&quot;true&quot; highlight=&quot;1,2,3&quot; htmlscript=&quot;false&quot; light=&quot;false&quot; ruler=&quot;false&quot; smarttabs=&quot;true&quot; tabsize=&quot;4&quot; toolbar=&quot;true&quot;]<?php _e('your code here', 'syntaxhighlighter'); ?>[/css]</code></li>
        <li><code>[code lang=&quot;js&quot;]<?php _e('your code here', 'syntaxhighlighter'); ?>[/code]</code></li>
        <li><code>[sourcecode language=&quot;plain&quot;]<?php _e('your code here', 'syntaxhighlighter'); ?>[/sourcecode]</code></li>
    </ul>
 
<?php $this->maybe_output_scripts(); ?>
 
</div>
 
<?php
    }
 
 
    // Handle the results of the settings page
    function save_settings() {
        // Capability check
        if ( !current_user_can('manage_options') )
            wp_die( __('Cheatin’ uh?') );
 
        // Form nonce check
        check_admin_referer('syntaxhighlighter');
 
        $defaults = false;
 
        if ( !empty($_POST['syntaxhighlighter-defaults']) ) {
            $settings = $this->defaultsettings;
            $defaults = true;
        } else {
            $settings = array();
 
            $settings['theme']      = ( !empty($_POST['syntaxhighlighter-theme']) && isset($this->themes[$_POST['syntaxhighlighter-theme']]) ) ? strtolower($_POST['syntaxhighlighter-theme']) : $this->defaultsettings['theme'];
 
            $settings['autolinks']  = ( !empty($_POST['syntaxhighlighter-autolinks']) )  ? 1 : ;
            $settings['collapse']   = ( !empty($_POST['syntaxhighlighter-collapse']) )   ? 1 : ;
            $settings['gutter']     = ( !empty($_POST['syntaxhighlighter-gutter']) )     ? 1 : ;
            $settings['light']      = ( !empty($_POST['syntaxhighlighter-light']) )      ? 1 : ;
            $settings['ruler']      = ( !empty($_POST['syntaxhighlighter-ruler']) )      ? 1 : ;
            $settings['smarttabs']  = ( !empty($_POST['syntaxhighlighter-smarttabs']) )  ? 1 : ;
            $settings['toolbar']    = ( !empty($_POST['syntaxhighlighter-toolbar']) )    ? 1 : ;
 
            $settings['classname']  = ( !empty($_POST['syntaxhighlighter-classname']) )       ? stripslashes( trim( $_POST['syntaxhighlighter-classname'] ) ) : $this->defaultsettings['classname'];
            $settings['firstline']  = (int) ( !empty($_POST['syntaxhighlighter-firstline']) ) ? stripslashes( $_POST['syntaxhighlighter-firstline'] )         : $this->defaultsettings['firstline'];
            $settings['fontsize']   = (int) ( !empty($_POST['syntaxhighlighter-fontsize']) )  ? stripslashes( $_POST['syntaxhighlighter-fontsize'] )          : $this->defaultsettings['fontsize'];
            $settings['tabsize']    = (int) ( !empty($_POST['syntaxhighlighter-tabsize']) )   ? stripslashes( $_POST['syntaxhighlighter-tabsize'] )           : $this->defaultsettings['tabsize'];
        }
 
        update_option( 'syntaxhighlighter_settings', $settings );
 
        // Redirect back to where we came from (the settings page)
        $redirectto = remove_query_arg( 'defaults', remove_query_arg( 'updated', wp_get_referer() ) );
        $redirectto = ( $defaults ) ? add_query_arg( 'defaults', 'true', $redirectto ) : add_query_arg( 'updated', 'true', $redirectto );
        wp_safe_redirect( $redirectto );
    }
 
 
    // PHP4 compatibility
    function SyntaxHighlighter() {
        $this->__construct();
    }
}
 
// Start this plugin once all other plugins are fully loaded
add_action( 'init', 'SyntaxHighlighter' ); function SyntaxHighlighter() { global $SyntaxHighlighter; $SyntaxHighlighter = new SyntaxHighlighter(); }
 
?>

这个文件里有个 我用代替了,使用的时候注意下就OK了。
最后就是测试很调试了。

Comments