Crayon Syntax Highlighter - Version 1.9.3

Version Description

  • Added Perl
  • Minor bugs fixed thanks to http://hahler.de
  • Fixed bug in js detecting PCs as Macs
  • Fixed IE bug preventing code from opening in a window
  • Fixed bug causing comment <p> tags being removed
Download this release

Release Info

Developer akarmenia
Plugin Icon wp plugin Crayon Syntax Highlighter
Version 1.9.3
Comparing to
See all releases

Code changes from version 1.9.2 to 1.9.3

crayon_settings_wp.class.php CHANGED
@@ -232,12 +232,11 @@ class CrayonSettingsWP {
232
 
233
  public static function remove_post($id) {
234
  self::load_posts();
235
- for ($i = 0; $i < count(self::$crayon_posts); $i++) {
236
- if (self::$crayon_posts[$i] == $id) {
237
- unset(self::$crayon_posts[$i]);
238
- break;
239
- }
240
  }
 
241
  self::save_posts();
242
  }
243
 
@@ -252,9 +251,11 @@ class CrayonSettingsWP {
252
 
253
  public static function remove_cache($name) {
254
  self::load_cache();
255
- if (in_array($name, self::$cache)) {
256
- unset(self::$cache[$name]);
 
257
  }
 
258
  self::save_cache();
259
  }
260
 
@@ -815,4 +816,4 @@ if (defined('ABSPATH') && is_admin()) {
815
  add_filter('plugin_row_meta', 'CrayonSettingsWP::plugin_row_meta', 10, 2);
816
  }
817
 
818
- ?>
232
 
233
  public static function remove_post($id) {
234
  self::load_posts();
235
+ $key = array_search($id, self::$crayon_posts);
236
+ if ($key === false) {
237
+ return;
 
 
238
  }
239
+ unset(self::$crayon_posts[$key]);
240
  self::save_posts();
241
  }
242
 
251
 
252
  public static function remove_cache($name) {
253
  self::load_cache();
254
+ $key = array_search($name, self::$cache);
255
+ if ($key === false) {
256
+ return;
257
  }
258
+ unset(self::$cache[$key]);
259
  self::save_cache();
260
  }
261
 
816
  add_filter('plugin_row_meta', 'CrayonSettingsWP::plugin_row_meta', 10, 2);
817
  }
818
 
819
+ ?>
crayon_wp.class.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: http://ak.net84.net/projects/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
- Version: 1.9.2
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  Text Domain: crayon-syntax-highlighter
@@ -329,7 +329,8 @@ class CrayonWP {
329
 
330
  // Search for shortcode in posts
331
  foreach ($posts as $post) {
332
- if (!in_array($post->ID, $crayon_posts)) {
 
333
  // If we get query for a page, then that page might have a template and load more posts containing Crayons
334
  // By this state, we would be unable to enqueue anything (header already written).
335
  if (CrayonGlobalSettings::val(CrayonSettings::SAFE_ENQUEUE) && is_page($wp_id)) {
@@ -341,7 +342,7 @@ class CrayonWP {
341
  }
342
  }
343
 
344
- $id_str = strval($post->ID);
345
 
346
  if ( isset(self::$post_captures[$id_str]) ) {
347
  // Don't capture twice
@@ -377,6 +378,8 @@ class CrayonWP {
377
  // Capture comment Crayons
378
  $captures = self::capture_crayons($comment->comment_ID, $comment->comment_content);
379
  self::$comment_captures[$id_str] = $captures['content'];
 
 
380
  if ($captures['has_captured'] === TRUE) {
381
  $enqueue = TRUE;
382
  self::$comment_queue[$id_str] = array();
@@ -505,14 +508,20 @@ class CrayonWP {
505
  return $the_content;
506
  }
507
 
508
- public static function comment_text($text) {
509
  global $comment;
510
  $comment_id = strval($comment->comment_ID);
511
- // Find if this post has Crayons
512
  if ( array_key_exists($comment_id, self::$comment_captures) ) {
513
  // Replace with IDs now that we need to
514
  $text = self::$comment_captures[$comment_id];
515
  }
 
 
 
 
 
 
 
516
  if ( array_key_exists($comment_id, self::$comment_queue) ) {
517
  // XXX We want the plain post content, no formatting
518
  $the_content_original = $text;
@@ -787,6 +796,9 @@ if (defined('ABSPATH')) {
787
  add_filter('the_content', 'CrayonWP::the_content', 100);
788
 
789
  if (CrayonGlobalSettings::val(CrayonSettings::COMMENTS)) {
 
 
 
790
  add_filter('comment_text', 'CrayonWP::comment_text', 100);
791
  }
792
 
3
  Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: http://ak.net84.net/projects/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
+ Version: 1.9.3
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  Text Domain: crayon-syntax-highlighter
329
 
330
  // Search for shortcode in posts
331
  foreach ($posts as $post) {
332
+ $wp_id = $post->ID;
333
+ if (!in_array($wp_id, $crayon_posts)) {
334
  // If we get query for a page, then that page might have a template and load more posts containing Crayons
335
  // By this state, we would be unable to enqueue anything (header already written).
336
  if (CrayonGlobalSettings::val(CrayonSettings::SAFE_ENQUEUE) && is_page($wp_id)) {
342
  }
343
  }
344
 
345
+ $id_str = strval($wp_id);
346
 
347
  if ( isset(self::$post_captures[$id_str]) ) {
348
  // Don't capture twice
378
  // Capture comment Crayons
379
  $captures = self::capture_crayons($comment->comment_ID, $comment->comment_content);
380
  self::$comment_captures[$id_str] = $captures['content'];
381
+ // $comment->comment_content = $captures['content']; // XXX testing!
382
+ // var_dump($comment->comment_content); exit;
383
  if ($captures['has_captured'] === TRUE) {
384
  $enqueue = TRUE;
385
  self::$comment_queue[$id_str] = array();
508
  return $the_content;
509
  }
510
 
511
+ public static function pre_comment_text($text) {
512
  global $comment;
513
  $comment_id = strval($comment->comment_ID);
 
514
  if ( array_key_exists($comment_id, self::$comment_captures) ) {
515
  // Replace with IDs now that we need to
516
  $text = self::$comment_captures[$comment_id];
517
  }
518
+ return $text;
519
+ }
520
+
521
+ public static function comment_text($text) {
522
+ global $comment;
523
+ $comment_id = strval($comment->comment_ID);
524
+ // Find if this post has Crayons
525
  if ( array_key_exists($comment_id, self::$comment_queue) ) {
526
  // XXX We want the plain post content, no formatting
527
  $the_content_original = $text;
796
  add_filter('the_content', 'CrayonWP::the_content', 100);
797
 
798
  if (CrayonGlobalSettings::val(CrayonSettings::COMMENTS)) {
799
+ /* XXX This is called first to match Crayons, then higher priority replaces after other filters
800
+ Prevents Crayon from being formatted by the filters, and also keeps original comment formatting */
801
+ add_filter('comment_text', 'CrayonWP::pre_comment_text', 1);
802
  add_filter('comment_text', 'CrayonWP::comment_text', 100);
803
  }
804
 
js/crayon.js CHANGED
@@ -304,7 +304,7 @@ var CrayonSyntax = new function() {
304
  }
305
 
306
  // Determine if Mac
307
- crayon[uid].mac = (jQuery(this).hasClass('crayon-os-mac').length != 0);
308
  });
309
  };
310
 
304
  }
305
 
306
  // Determine if Mac
307
+ crayon[uid].mac = jQuery(this).hasClass('crayon-os-mac');
308
  });
309
  };
310
 
js/jquery.popup.js CHANGED
@@ -45,14 +45,16 @@ function popupWindow(object, instanceSettings, beforeCallback, afterCallback) {
45
  ',location=' + settings.location +
46
  ',menuBar=' + settings.menubar;
47
 
48
- settings.windowName = settings.windowName || this.name;
49
- settings.windowURL = settings.windowURL || ( jQuery(this).attr('href') == '#' ? '' : this.href);
 
 
 
50
 
51
  var centeredY,centeredX;
52
 
53
  var win = null;
54
  if (settings.centerBrowser) {
55
-
56
  if (jQuery.browser.msie) {//hacked together for IE browsers
57
  centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
58
  centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
@@ -66,7 +68,7 @@ function popupWindow(object, instanceSettings, beforeCallback, afterCallback) {
66
  centeredX = (screen.width - settings.width)/2;
67
  win = window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY);
68
  } else {
69
- win = window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top)
70
  }
71
  if (win != null) {
72
  win.focus();
45
  ',location=' + settings.location +
46
  ',menuBar=' + settings.menubar;
47
 
48
+ settings.windowName = settings.windowName || jQuery(this).attr('name');
49
+ var href = jQuery(this).attr('href');
50
+ if (!settings.windowURL && !(href == '#') && !(href == '')) {
51
+ settings.windowURL = jQuery(this).attr('href');
52
+ }
53
 
54
  var centeredY,centeredX;
55
 
56
  var win = null;
57
  if (settings.centerBrowser) {
 
58
  if (jQuery.browser.msie) {//hacked together for IE browsers
59
  centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
60
  centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
68
  centeredX = (screen.width - settings.width)/2;
69
  win = window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY);
70
  } else {
71
+ win = window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top);
72
  }
73
  if (win != null) {
74
  win.focus();
langs/aliases.txt CHANGED
@@ -11,7 +11,8 @@ js javascript
11
  sh shell unix bash
12
  ruby rb
13
  ilogic logic inventor inv ilog
14
- pgsql sql mysql
15
- as flash swf fla
16
- ps powershell
17
- asm x86
 
11
  sh shell unix bash
12
  ruby rb
13
  ilogic logic inventor inv ilog
14
+ pgsql sql mysql
15
+ as flash swf fla
16
+ ps powershell
17
+ asm x86
18
+ perl pl
langs/extensions.txt CHANGED
@@ -12,4 +12,5 @@ objc m mm
12
  python py pyw pyc pyo pyd
13
  vb vbs
14
  ruby rb rbx rhtml
15
- as swf fla
 
12
  python py pyw pyc pyo pyd
13
  vb vbs
14
  ruby rb rbx rhtml
15
+ as swf fla
16
+ perl pl
langs/perl/compile.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ __DATA__
2
+ __WARN__
3
+ __END__
4
+ __DIE__
5
+ ARGVOUT
6
+ STDOUT
7
+ STDERR
8
+ BEGIN
9
+ STDIN
10
+ ARGV
langs/perl/perl.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### PERL LANGUAGE ###
2
+
3
+ # ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
4
+
5
+ NAME Perl
6
+ VERSION 1.9.2
7
+
8
+ COMMENT (?default)|(\#.*?$)
9
+ STRING (?default)|(<<<EOT.*?^EOT)
10
+ REGEX:PREPROCESSOR \b\w*/([^\r\n]|(?<=\\)/)+/\w*\b
11
+
12
+ TAG <\?php|<\?|\?>
13
+ STATEMENT \b(?alt:statement.txt)\b
14
+ RESERVED \b(?alt:reserved.txt)\b
15
+ COMPILE:CONSTANT \b(?alt:compile.txt)\b
16
+
17
+ ENTITY (?default)|\b[a-z_]\w*(::|->)
18
+ VARIABLE (\$|%)[a-z_]\w*\b
19
+ IDENTIFIER \b[a-z_]\w*\b\s*(?=\([^\)]*\))
20
+ CONSTANT \b[a-z_]\w*\b
21
+ OPERATOR (?default)
22
+ SYMBOL (?default)
langs/perl/reserved.txt ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ getprotobynumber
2
+ getprotobyname
3
+ gethostbyaddr
4
+ gethostbyname
5
+ getservbyname
6
+ getservbyport
7
+ getnetbyaddr
8
+ getnetbyname
9
+ endprotoent
10
+ getpeername
11
+ getpriority
12
+ getprotoent
13
+ getsockname
14
+ setpriority
15
+ setprotoent
16
+ endhostent
17
+ endservent
18
+ gethostent
19
+ getservent
20
+ getsockopt
21
+ sethostent
22
+ setservent
23
+ setsockopt
24
+ socketpair
25
+ endnetent
26
+ getnetent
27
+ localtime
28
+ prototype
29
+ quotemeta
30
+ rewinddir
31
+ setnetent
32
+ wantarray
33
+ closedir
34
+ dbmclose
35
+ endgrent
36
+ endpwent
37
+ formline
38
+ getgrent
39
+ getgrgid
40
+ getgrnam
41
+ getlogin
42
+ getpwent
43
+ getpwnam
44
+ getpwuid
45
+ readline
46
+ readlink
47
+ readpipe
48
+ setgrent
49
+ setpwent
50
+ shmwrite
51
+ shutdown
52
+ syswrite
53
+ truncate
54
+ binmode
55
+ connect
56
+ dbmopen
57
+ defined
58
+ getpgrp
59
+ getppid
60
+ lcfirst
61
+ opendir
62
+ package
63
+ readdir
64
+ require
65
+ reverse
66
+ seekdir
67
+ setpgrp
68
+ shmread
69
+ sprintf
70
+ symlink
71
+ syscall
72
+ sysopen
73
+ sysread
74
+ sysseek
75
+ telldir
76
+ ucfirst
77
+ unshift
78
+ waitpid
79
+ accept
80
+ caller
81
+ chroot
82
+ delete
83
+ exists
84
+ fileno
85
+ format
86
+ gmtime
87
+ import
88
+ length
89
+ listen
90
+ msgctl
91
+ msgget
92
+ msgrcv
93
+ msgsnd
94
+ printf
95
+ rename
96
+ return
97
+ rindex
98
+ scalar
99
+ select
100
+ semctl
101
+ semget
102
+ shmctl
103
+ shmget
104
+ socket
105
+ splice
106
+ substr
107
+ system
108
+ unlink
109
+ unpack
110
+ values
111
+ alarm
112
+ atan2
113
+ bless
114
+ chdir
115
+ chmod
116
+ chomp
117
+ chown
118
+ close
119
+ crypt
120
+ fcntl
121
+ flock
122
+ index
123
+ ioctl
124
+ local
125
+ lstat
126
+ mkdir
127
+ print
128
+ rmdir
129
+ semop
130
+ shift
131
+ sleep
132
+ split
133
+ srand
134
+ study
135
+ times
136
+ umask
137
+ undef
138
+ untie
139
+ utime
140
+ write
141
+ bind
142
+ chop
143
+ dump
144
+ each
145
+ eval
146
+ exec
147
+ exit
148
+ fork
149
+ getc
150
+ glob
151
+ goto
152
+ grep
153
+ join
154
+ keys
155
+ kill
156
+ link
157
+ open
158
+ pack
159
+ pipe
160
+ push
161
+ rand
162
+ read
163
+ recv
164
+ seek
165
+ send
166
+ sort
167
+ sqrt
168
+ stat
169
+ tell
170
+ tied
171
+ time
172
+ wait
173
+ warn
174
+ abs
175
+ chr
176
+ cos
177
+ die
178
+ eof
179
+ exp
180
+ hex
181
+ int
182
+ log
183
+ map
184
+ oct
185
+ ord
186
+ pop
187
+ pos
188
+ ref
189
+ sin
190
+ tie
191
+ vec
192
+ use
193
+ sub
194
+ new
195
+ lc
196
+ no
197
+ qq
198
+ qr
199
+ qw
200
+ qx
201
+ tr
202
+ uc
203
+ m
204
+ q
205
+ s
206
+ y
langs/perl/statement.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ continue
2
+ foreach
3
+ unless
4
+ elsif
5
+ until
6
+ while
7
+ reset
8
+ case
9
+ else
10
+ then
11
+ next
12
+ last
13
+ redo
14
+ for
15
+ xor
16
+ and
17
+ not
18
+ our
19
+ cmp
20
+ do
21
+ if
22
+ my
23
+ or
24
+ ne
25
+ eq
26
+ lt
27
+ gt
28
+ le
29
+ ge
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: akarmenia
3
  Donate link: http://bit.ly/crayondonate
4
  Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
5
  Requires at least: 3.0
6
- Tested up to: 3.3.1
7
- Stable tag: trunk
8
 
9
  Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
10
 
@@ -110,9 +110,13 @@ A handful of articles from others written about Crayon, thanks guys!
110
 
111
  * <a href="http://www.doitwithwp.com/displaying-code-in-wordpress-with-crayon-syntax-highlighter/" target="_blank">Displaying Code in WordPress with Crayon </a>
112
  * <a href="http://blog.boxedpages.net/2012/03/15/abap-syntaxhighlighting-in-wordpress/" target="_blank">ABAP Syntax Highlighting in WordPress (German)</a>
 
113
  * <a href="http://infodrug.ru/wordpress/kak-krasivo-vstavit-programmnyj-kod-v-wordpress-podsvetka-sintaksisa.html" target="_blank">Crayon Syntax Highlighter (Russian)</a>
114
  * <a href="http://n-wp.ru/11513" target="_blank">Crayon Syntax Highlighter (also Russian)</a>
115
  * <a href="http://kampungtoys.com/tag/crayon-syntax-highlighter/" target="_blank">How To Post Source Code</a>
 
 
 
116
 
117
  **Planned Features**
118
 
@@ -171,6 +175,13 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
171
 
172
  == Changelog ==
173
 
 
 
 
 
 
 
 
174
  = 1.9.2 =
175
  * Fixed an error preventing code containing HTML tags from being added using the Tag Editor in Visual mode
176
  * Fixed CSS for Mixed Highlighting (+)
3
  Donate link: http://bit.ly/crayondonate
4
  Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
5
  Requires at least: 3.0
6
+ Tested up to: 3.3.2
7
+ Stable tag: 1.9.3
8
 
9
  Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
10
 
110
 
111
  * <a href="http://www.doitwithwp.com/displaying-code-in-wordpress-with-crayon-syntax-highlighter/" target="_blank">Displaying Code in WordPress with Crayon </a>
112
  * <a href="http://blog.boxedpages.net/2012/03/15/abap-syntaxhighlighting-in-wordpress/" target="_blank">ABAP Syntax Highlighting in WordPress (German)</a>
113
+ * <a href="http://jstips.org/2012/04/23/crayon-syntax-highlighter-plugin/" target="_blank">Crayon Syntax Highlighter plugin</a>
114
  * <a href="http://infodrug.ru/wordpress/kak-krasivo-vstavit-programmnyj-kod-v-wordpress-podsvetka-sintaksisa.html" target="_blank">Crayon Syntax Highlighter (Russian)</a>
115
  * <a href="http://n-wp.ru/11513" target="_blank">Crayon Syntax Highlighter (also Russian)</a>
116
  * <a href="http://kampungtoys.com/tag/crayon-syntax-highlighter/" target="_blank">How To Post Source Code</a>
117
+ * http://wp-best-practices.asdf573189.com/home/good-plugins/crayon-syntax-highlighter/
118
+ * http://www.wplover.com/2155/crayon-syntax-highlighter-plugin/
119
+ * http://www.htmlandphp.com/scripts/crayon-syntax-highlighter.html
120
 
121
  **Planned Features**
122
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.9.3 =
179
+ * Added Perl
180
+ * Minor bugs fixed thanks to http://hahler.de
181
+ * Fixed bug in js detecting PCs as Macs
182
+ * Fixed IE bug preventing code from opening in a window
183
+ * Fixed bug causing comment &lt;p&gt; tags being removed
184
+
185
  = 1.9.2 =
186
  * Fixed an error preventing code containing HTML tags from being added using the Tag Editor in Visual mode
187
  * Fixed CSS for Mixed Highlighting (+)
util/crayon_util.class.php CHANGED
@@ -442,9 +442,9 @@ class CrayonUtil {
442
  // Detect if on a Mac or PC
443
  public static function is_mac($default = FALSE) {
444
  $user = $_SERVER['HTTP_USER_AGENT'];
445
- if (stripos($user, 'macintosh')) {
446
  return TRUE;
447
- } else if (stripos($user, 'windows') || stripos($user, 'linux')) {
448
  return FALSE;
449
  } else {
450
  return $default===TRUE;
442
  // Detect if on a Mac or PC
443
  public static function is_mac($default = FALSE) {
444
  $user = $_SERVER['HTTP_USER_AGENT'];
445
+ if (stripos($user, 'macintosh') !== FALSE) {
446
  return TRUE;
447
+ } else if (stripos($user, 'windows') !== FALSE || stripos($user, 'linux') !== FALSE) {
448
  return FALSE;
449
  } else {
450
  return $default===TRUE;
util/sample/perl.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ while (<STDIN>) {
2
+ $oldStr = $_;
3
+ foreach $k (keys %dic) {
4
+ s/$k/$dic{$k}/g;
5
+ }
6
+
7
+ $newStr = $_;
8
+ if ($oldStr ne $newStr) {
9
+ print STDERR "\n";
10
+ print STDERR "old>>$oldStr";
11
+ print STDERR "new>>$newStr";
12
+ }
13
+ print;
14
+ }