forked from Automattic/syntaxhighlighter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntaxhighlighter.php
1591 lines (1315 loc) · 70.8 KB
/
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
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php /*
**************************************************************************
Plugin Name: SyntaxHighlighter Evolved
Plugin URI: https://alex.blog/wordpress-plugins/syntaxhighlighter/
Version: 3.5.0
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/SyntaxHighlighter/">SyntaxHighlighter</a>. Includes a new editor block.
Author: Alex Mills (Viper007Bond)
Author URI: https://alex.blog/
Text Domain: syntaxhighlighter
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
**************************************************************************/
class SyntaxHighlighter {
// All of these variables are private. Filters are provided for things that can be modified.
var $pluginver = '3.5.0'; // Plugin version
var $agshver = false; // Alex Gorbatchev's SyntaxHighlighter version (dynamically set below due to v2 vs v3)
var $shfolder = false; // Controls what subfolder to load SyntaxHighlighter from (v2 or v3)
var $settings = array(); // Contains the user's settings
var $defaultsettings = array(); // Contains the default settings
var $brushes = array(); // Array of aliases => brushes
var $shortcodes = array(); // Array of shortcodes to use
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
var $codeformat = false; // If set, SyntaxHighlighter::get_code_format() will return this value
var $content_save_pre_ran = false; // It's possible for the "content_save_pre" filter to run multiple times, so keep track
// Initalize the plugin by registering the hooks
function __construct() {
if ( ! function_exists( 'do_shortcodes_in_html_tags' ) )
return;
// Load localization domain
load_plugin_textdomain( 'syntaxhighlighter' );
// Display hooks
add_filter( 'the_content', array( $this, 'parse_shortcodes' ), 7 ); // Posts
add_filter( 'comment_text', array( $this, 'parse_shortcodes_comment' ), 7 ); // Comments
add_filter( 'bp_get_the_topic_post_content', array( $this, 'parse_shortcodes' ), 7 ); // BuddyPress
// Into the database
add_filter( 'content_save_pre', array( $this, 'encode_shortcode_contents_slashed_noquickedit' ), 1 ); // Posts
add_filter( 'pre_comment_content', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // Comments
add_filter( 'group_forum_post_text_before_save', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // BuddyPress
add_filter( 'group_forum_topic_text_before_save', array( $this, 'encode_shortcode_contents_slashed' ), 1 ); // BuddyPress
// Out of the database for editing
add_filter( 'the_editor_content', array( $this, 'the_editor_content' ), 1 ); // Posts
add_filter( 'comment_edit_pre', array( $this, 'decode_shortcode_contents' ), 1 ); // Comments
add_filter( 'bp_get_the_topic_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress
add_filter( 'bp_get_the_topic_post_edit_text', array( $this, 'decode_shortcode_contents' ), 1 ); // BuddyPress
// Outputting SyntaxHighlighter's JS and CSS
add_action( 'wp_head', array( $this, 'output_header_placeholder' ), 15 );
add_action( 'admin_head', array( $this, 'output_header_placeholder' ), 15 ); // For comments
add_action( 'wp_footer', array( $this, 'maybe_output_scripts' ), 15 );
add_action( 'admin_footer', array( $this, 'maybe_output_scripts' ), 15 ); // For comments
// Admin hooks
add_action( 'admin_init', array( $this, 'register_setting' ) );
add_action( 'admin_menu', array( $this, 'register_settings_page' ) );
add_filter( 'mce_external_plugins', array( $this, 'add_tinymce_plugin' ) );
add_filter( 'save_post', array( $this, 'mark_as_encoded' ), 10, 2 );
add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
// Editor Blocks
if (
function_exists( 'parse_blocks' ) // WordPress 5.0+
|| function_exists( 'the_gutenberg_project' ) // Gutenberg plugin for older WordPress
) {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
add_action( 'the_content', array( $this, 'enable_brushes_used_in_blocks' ), 0 );
register_block_type(
'syntaxhighlighter/code',
array(
'render_callback' => array( $this, 'render_block' ),
)
);
}
// Register widget hooks
add_filter( 'widget_text', array( $this, 'widget_text_output' ), 7, 2 );
add_filter( 'widget_update_callback', array( $this, 'widget_text_save' ), 1, 4 );
add_filter( 'widget_form_callback', array( $this, 'widget_text_form' ), 1, 2 );
// Create array of default settings (you can use the filter to modify these)
$this->defaultsettings = (array) apply_filters( 'syntaxhighlighter_defaultsettings', array(
'theme' => 'default',
'loadallbrushes' => 0,
'shversion' => 3,
'title' => '',
'autolinks' => 1,
'classname' => '',
'collapse' => 0,
'firstline' => 1,
'gutter' => 1,
'htmlscript' => 0,
'light' => 0,
'padlinenumbers' => 'false',
'smarttabs' => 1,
'tabsize' => 4,
'toolbar' => 0,
'wraplines' => 1, // 2.x only
) );
// Create the settings array by merging the user's settings and the defaults
$usersettings = (array) get_option('syntaxhighlighter_settings');
$this->settings = wp_parse_args( $usersettings, $this->defaultsettings );
// Dynamically set folder and version names for SynaxHighlighter
if ( 2 == $this->settings['shversion'] ) {
$this->shfolder = 'syntaxhighlighter2';
$this->agshver = '2.1.364';
} else {
$this->shfolder = 'syntaxhighlighter3';
$this->agshver = '3.0.9b';
}
// Register brush scripts
wp_register_script( 'syntaxhighlighter-core', plugins_url( $this->shfolder . '/scripts/shCore.js', __FILE__ ), array(), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-as3', plugins_url( $this->shfolder . '/scripts/shBrushAS3.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-bash', plugins_url( $this->shfolder . '/scripts/shBrushBash.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-coldfusion', plugins_url( $this->shfolder . '/scripts/shBrushColdFusion.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-cpp', plugins_url( $this->shfolder . '/scripts/shBrushCpp.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-csharp', plugins_url( $this->shfolder . '/scripts/shBrushCSharp.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-css', plugins_url( $this->shfolder . '/scripts/shBrushCss.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-delphi', plugins_url( $this->shfolder . '/scripts/shBrushDelphi.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-diff', plugins_url( $this->shfolder . '/scripts/shBrushDiff.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-erlang', plugins_url( $this->shfolder . '/scripts/shBrushErlang.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-groovy', plugins_url( $this->shfolder . '/scripts/shBrushGroovy.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-java', plugins_url( $this->shfolder . '/scripts/shBrushJava.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-javafx', plugins_url( $this->shfolder . '/scripts/shBrushJavaFX.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-jscript', plugins_url( $this->shfolder . '/scripts/shBrushJScript.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-perl', plugins_url( $this->shfolder . '/scripts/shBrushPerl.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-php', plugins_url( $this->shfolder . '/scripts/shBrushPhp.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-plain', plugins_url( $this->shfolder . '/scripts/shBrushPlain.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-powershell', plugins_url( $this->shfolder . '/scripts/shBrushPowerShell.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-python', plugins_url( $this->shfolder . '/scripts/shBrushPython.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-ruby', plugins_url( $this->shfolder . '/scripts/shBrushRuby.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-scala', plugins_url( $this->shfolder . '/scripts/shBrushScala.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-sql', plugins_url( $this->shfolder . '/scripts/shBrushSql.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-vb', plugins_url( $this->shfolder . '/scripts/shBrushVb.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_script( 'syntaxhighlighter-brush-xml', plugins_url( $this->shfolder . '/scripts/shBrushXml.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
// Register some popular third-party brushes
wp_register_script( 'syntaxhighlighter-brush-clojure', plugins_url( 'third-party-brushes/shBrushClojure.js', __FILE__ ), array('syntaxhighlighter-core'), '20090602' );
wp_register_script( 'syntaxhighlighter-brush-fsharp', plugins_url( 'third-party-brushes/shBrushFSharp.js', __FILE__ ), array('syntaxhighlighter-core'), '20091003' );
wp_register_script( 'syntaxhighlighter-brush-latex', plugins_url( 'third-party-brushes/shBrushLatex.js', __FILE__ ), array('syntaxhighlighter-core'), '20090613' );
wp_register_script( 'syntaxhighlighter-brush-matlabkey', plugins_url( 'third-party-brushes/shBrushMatlabKey.js', __FILE__ ), array('syntaxhighlighter-core'), '20091209' );
wp_register_script( 'syntaxhighlighter-brush-objc', plugins_url( 'third-party-brushes/shBrushObjC.js', __FILE__ ), array('syntaxhighlighter-core'), '20091207' );
wp_register_script( 'syntaxhighlighter-brush-r', plugins_url( 'third-party-brushes/shBrushR.js', __FILE__ ), array('syntaxhighlighter-core'), '20100919' );
// Register theme stylesheets
wp_register_style( 'syntaxhighlighter-core', plugins_url( $this->shfolder . '/styles/shCore.css', __FILE__ ), array(), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-default', plugins_url( $this->shfolder . '/styles/shThemeDefault.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-django', plugins_url( $this->shfolder . '/styles/shThemeDjango.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-eclipse', plugins_url( $this->shfolder . '/styles/shThemeEclipse.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-emacs', plugins_url( $this->shfolder . '/styles/shThemeEmacs.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-fadetogrey', plugins_url( $this->shfolder . '/styles/shThemeFadeToGrey.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-midnight', plugins_url( $this->shfolder . '/styles/shThemeMidnight.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
wp_register_style( 'syntaxhighlighter-theme-rdark', plugins_url( $this->shfolder . '/styles/shThemeRDark.css', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
// Create list of brush aliases and map them to their real brushes
// The key is the language alias
// The value is the script handle suffix: syntaxhighlighter-brush-ThisBitHere (your plugin needs to register the script itself)
$this->brushes = (array) apply_filters( 'syntaxhighlighter_brushes', array(
'as3' => 'as3',
'actionscript3' => 'as3',
'bash' => 'bash',
'shell' => 'bash',
'coldfusion' => 'coldfusion',
'cf' => 'coldfusion',
'clojure' => 'clojure',
'clj' => 'clojure',
'cpp' => 'cpp',
'c' => 'cpp',
'c-sharp' => 'csharp',
'csharp' => 'csharp',
'css' => 'css',
'delphi' => 'delphi',
'pas' => 'delphi',
'pascal' => 'delphi',
'diff' => 'diff',
'patch' => 'diff',
'erl' => 'erlang',
'erlang' => 'erlang',
'fsharp' => 'fsharp',
'groovy' => 'groovy',
'java' => 'java',
'jfx' => 'javafx',
'javafx' => 'javafx',
'js' => 'jscript',
'jscript' => 'jscript',
'javascript' => 'jscript',
'latex' => 'latex', // Not used as a shortcode
'tex' => 'latex',
'matlab' => 'matlabkey',
'objc' => 'objc',
'obj-c' => 'objc',
'perl' => 'perl',
'pl' => 'perl',
'php' => 'php',
'plain' => 'plain',
'text' => 'plain',
'ps' => 'powershell',
'powershell' => 'powershell',
'py' => 'python',
'python' => 'python',
'r' => 'r', // Not used as a shortcode
'splus' => 'r',
'rails' => 'ruby',
'rb' => 'ruby',
'ror' => 'ruby',
'ruby' => 'ruby',
'scala' => 'scala',
'sql' => 'sql',
'vb' => 'vb',
'vbnet' => 'vb',
'xml' => 'xml',
'xhtml' => 'xml',
'xslt' => 'xml',
'html' => 'xml',
) );
$this->brush_names = (array) apply_filters( 'syntaxhighlighter_brush_names', array(
'as3' => __( 'ActionScript', 'syntaxhighlighter' ),
'bash' => __( 'BASH / Shell', 'syntaxhighlighter' ),
'coldfusion' => __( 'ColdFusion', 'syntaxhighlighter' ),
'clojure' => __( 'Clojure', 'syntaxhighlighter' ),
'cpp' => __( 'C / C++', 'syntaxhighlighter' ),
'csharp' => __( 'C#', 'syntaxhighlighter' ),
'css' => __( 'CSS', 'syntaxhighlighter' ),
'delphi' => __( 'Delphi / Pascal', 'syntaxhighlighter' ),
'diff' => __( 'diff / patch', 'syntaxhighlighter' ),
'erlang' => __( 'Erlang', 'syntaxhighlighter' ),
'fsharp' => __( 'F#', 'syntaxhighlighter' ),
'groovy' => __( 'Groovy', 'syntaxhighlighter' ),
'java' => __( 'Java', 'syntaxhighlighter' ),
'javafx' => __( 'JavaFX', 'syntaxhighlighter' ),
'jscript' => __( 'JavaScript', 'syntaxhighlighter' ),
'latex' => __( 'LaTeX', 'syntaxhighlighter' ),
'matlabkey' => __( 'MATLAB', 'syntaxhighlighter' ),
'objc' => __( 'Objective-C', 'syntaxhighlighter' ),
'perl' => __( 'Perl', 'syntaxhighlighter' ),
'php' => __( 'PHP', 'syntaxhighlighter' ),
'plain' => __( 'Plain Text', 'syntaxhighlighter' ),
'powershell' => __( 'PowerShell', 'syntaxhighlighter' ),
'python' => __( 'Python', 'syntaxhighlighter' ),
'r' => __( 'R', 'syntaxhighlighter' ),
'ruby' => __( 'Ruby / Ruby on Rails', 'syntaxhighlighter' ),
'scala' => __( 'Scala', 'syntaxhighlighter' ),
'sql' => __( 'SQL', 'syntaxhighlighter' ),
'vb' => __( 'Visual Basic', 'syntaxhighlighter' ),
'xml' => __( 'HTML / XHTML / XML / XSLT', 'syntaxhighlighter' ),
) );
// Add any custom brushes that aren't making use of the newer "syntaxhighlighter_brush_names" filter.
foreach ( $this->brushes as $slug => $language ) {
if ( ! isset( $this->brush_names[ $language ] ) ) {
$this->brush_names[ $language ] = $slug;
}
}
// Create a list of shortcodes to use. You can use the filter to add/remove ones.
// If the language/lang parameter is left out, it's assumed the shortcode name is the language.
// If that's invalid, then "plain" is used.
$this->shortcodes = array( 'sourcecode', 'source', 'code' );
$this->shortcodes = array_merge( $this->shortcodes, array_keys( $this->brushes ) );
// Remove some shortcodes we don't want while still supporting them as language values
unset( $this->shortcodes[array_search( 'latex', $this->shortcodes )] ); // Remove "latex" shortcode (it'll collide)
unset( $this->shortcodes[array_search( 'r', $this->shortcodes )] ); // Remove "r" shortcode (too short)
$this->shortcodes = (array) apply_filters( 'syntaxhighlighter_shortcodes', $this->shortcodes );
// Register each shortcode with a placeholder callback so that strip_shortcodes() will work
// The proper callback and such is done in SyntaxHighlighter::shortcode_hack()
foreach ( $this->shortcodes as $shortcode )
add_shortcode( $shortcode, '__return_empty_string' );
// Create list of themes and their human readable names
// Plugins can add to this list: http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/adding-a-new-theme/
$this->themes = (array) apply_filters( 'syntaxhighlighter_themes', array(
'default' => __( 'Default', 'syntaxhighlighter' ),
'django' => __( 'Django', 'syntaxhighlighter' ),
'eclipse' => __( 'Eclipse', 'syntaxhighlighter' ),
'emacs' => __( 'Emacs', 'syntaxhighlighter' ),
'fadetogrey' => __( 'Fade to Grey', 'syntaxhighlighter' ),
'midnight' => __( 'Midnight', 'syntaxhighlighter' ),
'rdark' => __( 'RDark', 'syntaxhighlighter' ),
'none' => __( '[None]', 'syntaxhighlighter' ),
) );
// Other special characters that need to be encoded before going into the database (namely to work around kses)
$this->specialchars = (array) apply_filters( 'syntaxhighlighter_specialchars', array(
'\0' => '\0',
) );
}
// Register the settings page
function register_settings_page() {
add_options_page( __( 'SyntaxHighlighter Settings', 'syntaxhighlighter' ), __( 'SyntaxHighlighter', 'syntaxhighlighter' ), 'manage_options', 'syntaxhighlighter', array( $this, 'settings_page' ) );
}
// Register the plugin's setting
function register_setting() {
register_setting( 'syntaxhighlighter_settings', 'syntaxhighlighter_settings', array( $this, 'validate_settings' ) );
}
// Enqueue block assets for the Editor
function enqueue_block_editor_assets() {
wp_enqueue_script(
'syntaxhighlighter-blocks',
plugins_url( 'dist/blocks.build.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ),
( defined( 'WP_DEBUG' ) && WP_DEBUG )
? filemtime( plugin_dir_path( __FILE__ ) . 'dist/blocks.build.js' )
: $this->pluginver
);
// WordPress 5.0+ only, no Gutenberg plugin support
if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( 'syntaxhighlighter-blocks', 'syntaxhighlighter' );
}
natcasesort( $this->brush_names );
$settings = (object) array(
'language' => (object) array(
'supported' => true,
'default' => 'plain'
),
'lineNumbers' => (object) array(
'supported' => true,
'default' => (bool) $this->settings['gutter'],
),
'firstLineNumber' => (object) array(
'supported' => true,
'default' => $this->settings['firstline'],
),
'highlightLines' => (object) array(
'supported' => true,
'default' => '',
),
'wrapLines' => (object) array(
'supported' => ( '2' == $this->settings['shversion'] ),
'default' => (bool) $this->settings['wraplines'],
),
'makeURLsClickable' => (object) array(
'supported' => true,
'default' => (bool) $this->settings['autolinks'],
),
);
wp_add_inline_script(
'syntaxhighlighter-blocks',
sprintf( '
var syntaxHighlighterData = {
brushes: %s,
settings: %s,
};',
json_encode( $this->brush_names ),
json_encode( $settings )
),
'before'
);
}
/**
* Enable the brushes that are used in blocks.
*
* For the shortcode, brushes are activated by `shortcode_callback()`, but that won't detect brushes that were
* used in blocks. For that, we need to extract the data from the block's attributes.
*
* @since 3.3.0
*
* @param string $content The post content.
*
* @return string Unmodified $content.
*/
function enable_brushes_used_in_blocks( $content ) {
/*
* Return early on the backend because SyntaxHighlighting is only active on the front end, see
* `syntaxHighlighterCode::edit()` block for details.
*/
if ( is_admin() ) {
return $content;
}
// Lower overhead than a full parse.
if (
! has_block( 'syntaxhighlighter/code', $content )
&& ! has_block( 'core/block', $content ) // Reusable
) {
return $content;
}
if ( function_exists( 'parse_blocks' ) ) { // WP 5.0+
$blocks = parse_blocks( $content );
} elseif ( Function_exists( 'gutenberg_parse_blocks' ) ) { // Gutenberg plugin
$blocks = gutenberg_parse_blocks( $content );
} else {
return $content;
}
foreach ( $blocks as $block ) {
if ( empty( $block['blockName'] ) ) {
continue;
}
switch ( $block['blockName'] ) {
// Normal block usage
case 'syntaxhighlighter/code':
$language = ( ! empty( $block['attrs']['language'] ) ) ? $block['attrs']['language'] : 'plain';
if ( in_array( $language, $this->brushes, true ) ) {
$this->usedbrushes[ $this->brushes[ $language ] ] = true;
}
break;
// But the block could also be used inside of a reusable block
case 'core/block':
/**
* Rather than going down the block parsing rabbit hole of dynamic blocks,
* let's just hook in post-render and look for our HTML.
*/
add_filter( 'the_content', array( $this, 'enable_brushes_via_raw_html_parsing' ), 10 );
break;
}
}
return $content;
}
/**
* Parses raw HTML looking for SyntaxHighlighter's <pre> tags and queues brushes
* for the languages used.
*
* This filter only runs when a reusable block is used in a post.
* It was easier to implement than loading the block, which then could
* have child blocks and so forth. Technically this means that we're
* parsing any regular SyntaxHighlighter blocks again, but oh well. :)
*
* @since 3.4.2
*
* @param string $content The post content.
*
* @return string Unmodified $content.
*/
public function enable_brushes_via_raw_html_parsing( $content ) {
if ( false === strpos( $content,'<pre class="wp-block-syntaxhighlighter-code' ) ) {
return $content;
}
preg_match_all(
'/<pre class="wp-block-syntaxhighlighter-code brush: ([^;]+);/',
$content,
$languages,
PREG_PATTERN_ORDER
);
if ( is_array( $languages ) ) {
foreach ( $languages[1] as $language ) {
if ( in_array( $language, $this->brushes, true ) ) {
$this->usedbrushes[ $this->brushes[ $language ] ] = true;
}
}
}
return $content;
}
/**
* Renders the content of the Gutenberg block on the front end
* using the shortcode callback. This ensures one source of truth
* and allows for forward compatibility.
*
* @param string $content The block's content.
*
* @return string The rendered content.
*/
public function render_block( $attributes, $content ) {
$remaps = array(
'lineNumbers' => 'gutter',
'firstLineNumber' => 'firstline',
'highlightLines' => 'highlight',
'wrapLines' => 'wraplines',
'makeURLsClickable' => 'autolinks',
);
foreach ( $remaps as $from => $to ) {
if ( isset( $attributes[ $from ] ) ) {
if ( is_bool( $attributes[ $from ] ) ) {
$attributes[ $to ] = ( $attributes[ $from ] ) ? '1' : '0';
} else {
$attributes[ $to ] = $attributes[ $from ];
}
unset( $attributes[ $from ] );
}
}
$code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );
// Undo escaping done by WordPress
$code = str_replace( '<', '<', $code );
return $this->shortcode_callback( $attributes, $code, 'code' );
}
// Add the custom TinyMCE plugin which wraps plugin shortcodes in <pre> in TinyMCE
function add_tinymce_plugin( $plugins ) {
global $tinymce_version;
add_action( 'admin_print_footer_scripts', array( $this, 'output_shortcodes_for_tinymce' ), 9 );
if ( substr( $tinymce_version, 0, 1 ) < 4 ) {
$plugins['syntaxhighlighter'] = plugins_url( 'syntaxhighlighter_mce.js', __FILE__ );
} else {
$plugins['syntaxhighlighter'] = add_query_arg( 'ver', $this->pluginver, plugins_url( 'syntaxhighlighter_mce-4.js', __FILE__ ) );
wp_enqueue_script( 'syntaxhighlighter', plugins_url( 'syntaxhighlighter.js', __FILE__ ), array(), false, true );
}
return $plugins;
}
// Break the TinyMCE cache
function break_tinymce_cache( $version ) {
return $version . '-sh' . $this->pluginver;
}
// Add a "Settings" link to the plugins page
function settings_link( $links, $file ) {
static $this_plugin;
if( empty($this_plugin) )
$this_plugin = plugin_basename(__FILE__);
if ( $file == $this_plugin )
$links[] = '<a href="' . admin_url( 'options-general.php?page=syntaxhighlighter' ) . '">' . __( 'Settings', 'syntaxhighlighter' ) . '</a>';
return $links;
}
// Output list of shortcode tags for the TinyMCE plugin
function output_shortcodes_for_tinymce() {
$shortcodes = array();
foreach ( $this->shortcodes as $shortcode )
$shortcodes[] = preg_quote( $shortcode );
echo "<script type='text/javascript'>\n";
echo " var syntaxHLcodes = '" . implode( '|', $shortcodes ) . "';\n";
echo "</script>\n";
}
/**
* Process only this plugin's shortcodes.
*
* If we waited for the normal do_shortcode() call at priority 11,
* then wpautop() and maybe others would mangle all of the code.
*
* So instead we hook in earlier with this function and process
* just this plugins's shortcodes. To do this requires some trickery.
*
* First we need to clear out all existing shortcodes, then register
* just this plugin's ones, process them, and then restore the original
* list of shortcodes.
*
* To make matters more complicated, if someone has done [[code]foo[/code]]
* in order to display the shortcode (not render it), then do_shortcode()
* will strip the outside brackets and when do_shortcode() runs a second
* time later on, it will render it.
*
* So instead before do_shortcode() runs for the first time, we add
* even more brackets escaped shortcodes in order to result in
* the shortcodes actually being displayed instead rendered.
*
* We only need to do this for this plugin's shortcodes however
* as all other shortcodes such as [[gallery]] will be untouched
* by this pass of do_shortcode.
*
* Phew!
*
* @param string $content The post content.
* @param array $callback The callback function that should be used for add_shortcode()
* @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped.
*
* @return string The filtered content, with this plugin's shortcodes parsed.
*/
function shortcode_hack( $content, $callback, $ignore_html = true ) {
global $shortcode_tags;
// Regex is slow. Let's do some strpos() checks first.
if ( ! $this->string_has_shortcodes( $content, $this->shortcodes ) ) {
return $content;
}
// Backup current registered shortcodes and clear them all out
$orig_shortcode_tags = $shortcode_tags;
remove_all_shortcodes();
// Register all of this plugin's shortcodes
foreach ( $this->shortcodes as $shortcode ) {
add_shortcode( $shortcode, $callback );
}
$regex = '/' . get_shortcode_regex( $this->shortcodes ) . '/';
// Parse the shortcodes (only this plugins's are registered)
if ( $ignore_html ) {
// Extra escape escaped shortcodes because do_shortcode_tag() called by do_shortcode() is going to strip a pair of square brackets when it runs
$content = preg_replace_callback(
$regex,
array( $this, 'shortcode_hack_extra_escape_escaped_shortcodes' ),
$content
);
// Normal, safe parsing
$content = do_shortcode( $content, true );
} else {
// Extra escape escaped shortcodes because do_shortcode_tag() called by do_shortcode() is going to strip a pair of square brackets when it runs.
// Then call do_shortcode_tag(). This is basically do_shortcode() without calling do_shortcodes_in_html_tags() which breaks things.
// For context, see https://wordpress.org/support/topic/php-opening-closing-tags-break-code-blocks
$content = preg_replace_callback(
$regex,
array( $this, 'shortcode_hack_extra_escape_escaped_shortcodes_and_parse' ),
$content
);
}
// Put the original shortcodes back
$shortcode_tags = $orig_shortcode_tags;
return $content;
}
/**
* A quick checker to see if any of this plugin's shortcodes are in use in a string.
* Since all of the tags can't be self-closing, we look for the closing tag.
*
* @param string $string The string to look through. This is a post's contents usually.
* @param array $shortcodes The array of shortcodes to look for.
*
* @return bool Whether any shortcode usage was found.
*/
function string_has_shortcodes( $string, $shortcodes ) {
foreach ( $shortcodes as $shortcode ) {
if ( false !== strpos( $string, "[/{$shortcode}]" ) ) {
return true;
}
}
return false;
}
/**
* Add extra square brackets around escaped shortcodes.
* This is to counteract the beginning of the do_shortcode_tag() function.
*
* @param array $match The array of matches generated by get_shortcode_regex()
*
* @return string What should be placed into the post content. In this case it's the raw match, or an extra-wrapped raw match.
*/
function shortcode_hack_extra_escape_escaped_shortcodes( $match ) {
if ( $match[1] == '[' && $match[6] == ']' ) {
return '[' . $match[0] . ']';
}
return $match[0];
}
/**
* This is a combination of this class's shortcode_hack_extra_escape_escaped_shortcodes()
* and do_shortcode_tag() for performance reasons so that we don't have to run some regex twice.
*
* @param array $match Regular expression match array.
*
* @return string|false False on failure, otherwise a parse shortcode tag.
*/
function shortcode_hack_extra_escape_escaped_shortcodes_and_parse( $match ) {
$match[0] = $this->shortcode_hack_extra_escape_escaped_shortcodes( $match );
return do_shortcode_tag( $match );
}
// 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
function encode_shortcode_contents( $content ) {
return $this->shortcode_hack( $content, array( $this, 'encode_shortcode_contents_callback' ), false );
}
// HTML entity encode the contents of shortcodes. Expects slashed content.
function encode_shortcode_contents_slashed( $content ) {
return addslashes( $this->encode_shortcode_contents( stripslashes( $content ) ) );
}
// HTML entity encode the contents of shortcodes. Expects slashed content. Aborts if AJAX.
function encode_shortcode_contents_slashed_noquickedit( $content ) {
// In certain weird circumstances, the content gets run through "content_save_pre" twice
// Keep track and don't allow this filter to be run twice
// I couldn't easily figure out why this happens and didn't bother looking into it further as this works fine
if ( true == $this->content_save_pre_ran ) {
return $content;
}
$this->content_save_pre_ran = true;
// Post quick edits aren't decoded for display, so we don't need to encode them (again)
// This also aborts for (un)trashing to avoid extra encoding.
if ( empty( $_POST ) || ( ! empty( $_POST['action'] ) && 'inline-save' == $_POST['action'] ) ) {
return $content;
}
return $this->encode_shortcode_contents_slashed( $content );
}
// HTML entity decode the contents of shortcodes
function decode_shortcode_contents( $content ) {
return $this->shortcode_hack( $content, array( $this, 'decode_shortcode_contents_callback' ), false );
}
// The callback function for SyntaxHighlighter::encode_shortcode_contents()
function encode_shortcode_contents_callback( $atts, $code = '', $tag = false ) {
$this->encoded = true;
$code = str_replace( array_keys($this->specialchars), array_values($this->specialchars), htmlspecialchars( $code ) );
return '[' . $tag . $this->atts2string( $atts ) . "]{$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;
$code = str_replace( array_values($this->specialchars), array_keys($this->specialchars), htmlspecialchars_decode( $code ) );
return '[' . $tag . $this->atts2string( $atts, $quotes ) . "]{$code}[/$tag]";
}
// Dynamically format the post content for the edit form
function the_editor_content( $content ) {
global $post;
// New code format (stored encoded in database)
if ( 2 == $this->get_code_format( $post ) ) {
// If TinyMCE is disabled or the HTML tab is set to be displayed first, we need to decode the HTML
if ( !user_can_richedit() || 'html' == wp_default_editor() )
$content = $this->decode_shortcode_contents( $content );
}
// Old code format (stored raw in database)
else {
// If TinyMCE is enabled and is set to be displayed first, we need to encode the HTML
if ( user_can_richedit() && 'html' != wp_default_editor() )
$content = $this->encode_shortcode_contents( $content );
}
return $content;
}
// Run SyntaxHighlighter::encode_shortcode_contents() on the contents of the text widget
function widget_text_save( $instance, $new_instance, $old_instance, $widgetclass ) {
if ( 'text' == $widgetclass->id_base ) {
// Re-save the widget settings but this time with the shortcode contents encoded
$new_instance['text'] = $this->encode_shortcode_contents( $new_instance['text'] );
$instance = $widgetclass->update( $new_instance, $old_instance );
// And flag it as encoded
$instance['syntaxhighlighter_encoded'] = true;
}
return $instance;
}
// Run SyntaxHighlighter::decode_shortcode_contents_callback() on the contents of the text widget form
function widget_text_form( $instance, $widgetclass ) {
if ( 'text' == $widgetclass->id_base && !empty($instance['syntaxhighlighter_encoded']) ) {
$instance['text'] = $this->shortcode_hack( $instance['text'], array( $this, 'decode_shortcode_contents_callback' ) );
}
return $instance;
}
// Run SyntaxHighlighter::parse_shortcodes() on the contents of a text widget
function widget_text_output( $content, $instance = false ) {
$this->codeformat = ( false === $instance || empty($instance['syntaxhighlighter_encoded']) ) ? 1 : 2;
$content = $this->parse_shortcodes( $content );
$this->codeformat = false;
return $content;
}
// Run SyntaxHighlighter::parse_shortcodes() on the contents of a comment
function parse_shortcodes_comment( $content ) {
$this->codeformat = 2;
$content = $this->parse_shortcodes( $content );
$this->codeformat = false;
return $content;
}
// This function determines what version of SyntaxHighlighter was used when the post was written
// This is because the code was stored differently for different versions of SyntaxHighlighter
function get_code_format( $post ) {
if ( false !== $this->codeformat )
return $this->codeformat;
if ( empty($post) )
$post = new stdClass();
if ( null !== $version = apply_filters( 'syntaxhighlighter_pre_getcodeformat', null, $post ) )
return $version;
$version = ( empty($post->ID) || get_post_meta( $post->ID, '_syntaxhighlighter_encoded', true ) || get_post_meta( $post->ID, 'syntaxhighlighter_encoded', true ) ) ? 2 : 1;
return apply_filters( 'syntaxhighlighter_getcodeformat', $version, $post );
}
// 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;
delete_post_meta( $post_ID, 'syntaxhighlighter_encoded' ); // Previously used
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[0]) ) {
if ( empty($atts['language']) )
$atts['language'] = $atts[0];
unset($atts[0]);
}
$strings = array();
foreach ( $atts as $key => $value )
$strings[] = ( $quotes ) ? $key . '="' . esc_attr( $value ) . '"' : $key . '=' . esc_attr( $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 an anchor in the header for the Javascript to use.
// In the <head>, we don't know if we'll need this plugin's CSS and JavaScript yet but we will in the footer.
function output_header_placeholder() {
echo '<style type="text/css" id="syntaxhighlighteranchor"></style>' . "\n";
}
// Output any needed scripts. This is meant for the footer.
function maybe_output_scripts() {
global $wp_styles;
if ( 1 == $this->settings['loadallbrushes'] )
$this->usedbrushes = array_flip( array_values( $this->brushes ) );
if ( empty($this->usedbrushes) )
return;
$scripts = array();
foreach ( $this->usedbrushes as $brush => $unused )
$scripts[] = 'syntaxhighlighter-brush-' . strtolower( $brush );
wp_print_scripts( $scripts );
// Stylesheets can't be in the footer, so inject them via Javascript
echo "<script type='text/javascript'>\n";
echo " (function(){\n";
echo " var corecss = document.createElement('link');\n";
echo " var themecss = document.createElement('link');\n";
if ( !is_a($wp_styles, 'WP_Styles') )
$wp_styles = new WP_Styles();
$needcore = false;
if ( 'none' == $this->settings['theme'] ) {
$needcore = true;
} else {
$theme = ( !empty($this->themes[$this->settings['theme']]) ) ? strtolower($this->settings['theme']) : $this->defaultsettings['theme'];
$theme = 'syntaxhighlighter-theme-' . $theme;
// See if the requested theme has been registered
if ( !empty($wp_styles) && !empty($wp_styles->registered) && !empty($wp_styles->registered[$theme]) && !empty($wp_styles->registered[$theme]->src) ) {
// Users can register their own stylesheet and may opt to not load the core stylesheet if they wish for some reason
if ( is_array($wp_styles->registered[$theme]->deps) && in_array( 'syntaxhighlighter-core', $wp_styles->registered[$theme]->deps ) )
$needcore = true;
}
// Otherwise use the default theme
else {
$theme = 'syntaxhighlighter-theme-' . $this->defaultsettings['theme'];
$needcore = true;
}
}
if ( $needcore && !empty($wp_styles) && !empty($wp_styles->registered) && !empty($wp_styles->registered['syntaxhighlighter-core']) && !empty($wp_styles->registered['syntaxhighlighter-core']->src) ) :
$corecssurl = add_query_arg( 'ver', $this->agshver, $wp_styles->registered['syntaxhighlighter-core']->src );
$corecssurl = apply_filters( 'syntaxhighlighter_csscoreurl', $corecssurl );
?>
var corecssurl = "<?php echo esc_js( $corecssurl ); ?>";
if ( corecss.setAttribute ) {
corecss.setAttribute( "rel", "stylesheet" );
corecss.setAttribute( "type", "text/css" );
corecss.setAttribute( "href", corecssurl );
} else {
corecss.rel = "stylesheet";
corecss.href = corecssurl;
}
document.getElementsByTagName("head")[0].insertBefore( corecss, document.getElementById("syntaxhighlighteranchor") );
<?php
endif; // Endif $needcore
if ( 'none' != $this->settings['theme'] ) : ?>
var themecssurl = "<?php echo esc_js( apply_filters( 'syntaxhighlighter_cssthemeurl', add_query_arg( 'ver', $this->agshver, $wp_styles->registered[$theme]->src ) ) ); ?>";
if ( themecss.setAttribute ) {
themecss.setAttribute( "rel", "stylesheet" );
themecss.setAttribute( "type", "text/css" );
themecss.setAttribute( "href", themecssurl );
} else {
themecss.rel = "stylesheet";
themecss.href = themecssurl;
}
//document.getElementById("syntaxhighlighteranchor").appendChild(themecss);
document.getElementsByTagName("head")[0].insertBefore( themecss, document.getElementById("syntaxhighlighteranchor") );
<?php
endif; // Endif none != theme
echo " })();\n";
switch ( $this->settings['shversion'] ) {
case 2:
echo " SyntaxHighlighter.config.clipboardSwf = '" . esc_js( apply_filters( 'syntaxhighlighter_clipboardurl', plugins_url( 'syntaxhighlighter2/scripts/clipboard.swf', __FILE__ ) ) ) . "';\n";
echo " SyntaxHighlighter.config.strings.expandSource = '" . $this->js_escape_singlequotes( __( 'show 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";
break;
case 3:
echo " SyntaxHighlighter.config.strings.expandSource = '" . $this->js_escape_singlequotes( __( '+ expand source', '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";
break;
}