Version Description
- Fixed a crucial but hard to spot bug causing Crayon code to break by incorrectly handling ignored Crayons
- Added functions to generate Crayons when given Crayon tags in strings like the post content
- Added width:100%; so CSS float works
- Removed bit.ly links from this readme
Download this release
Release Info
Developer | akarmenia |
Plugin | Crayon Syntax Highlighter |
Version | 1.9.7 |
Comparing to | |
See all releases |
Code changes from version 1.9.4 to 1.9.7
- .gitignore +0 -6
- crayon_highlighter.class.php +4 -4
- crayon_wp.class.php +56 -38
- css/style.css +1 -0
- global.php +2 -2
- readme.txt +43 -12
.gitignore
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
.svn
|
2 |
-
.project
|
3 |
-
Thumbs.db
|
4 |
-
.DS_Store*
|
5 |
-
.settings
|
6 |
-
.buildpath
|
|
|
|
|
|
|
|
|
|
|
|
crayon_highlighter.class.php
CHANGED
@@ -292,13 +292,13 @@ class CrayonHighlighter {
|
|
292 |
$lines = array();
|
293 |
foreach ($array as $line) {
|
294 |
// Check for ranges
|
295 |
-
if (strpos($line, '-')) {
|
296 |
-
$ranges = CrayonUtil::range_str($
|
297 |
$lines = array_merge($lines, $ranges);
|
298 |
} else {
|
299 |
// Otherwise check the string for a number
|
300 |
-
$line =
|
301 |
-
if ($line !==
|
302 |
$lines[] = $line;
|
303 |
}
|
304 |
}
|
292 |
$lines = array();
|
293 |
foreach ($array as $line) {
|
294 |
// Check for ranges
|
295 |
+
if (strpos($line, '-') !== FALSE) {
|
296 |
+
$ranges = CrayonUtil::range_str($line);
|
297 |
$lines = array_merge($lines, $ranges);
|
298 |
} else {
|
299 |
// Otherwise check the string for a number
|
300 |
+
$line = intval($line);
|
301 |
+
if ($line !== 0) {
|
302 |
$lines[] = $line;
|
303 |
}
|
304 |
}
|
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.
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
Text Domain: crayon-syntax-highlighter
|
@@ -76,10 +76,16 @@ class CrayonWP {
|
|
76 |
|
77 |
const REGEX_ID = '#(?<!\$)\[\s*crayon#mi';
|
78 |
//const REGEX_WITH_ID = '#(\[\s*crayon-\w+)\b([^\]]*["\'])(\s*/?\s*\])#mi';
|
79 |
-
const REGEX_WITH_ID = '#\[\s*(crayon-\w+)\b[^\]]*\
|
80 |
|
81 |
const MODE_NORMAL = 0, MODE_JUST_CODE = 1, MODE_PLAIN_CODE = 2;
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
// Methods ================================================================
|
84 |
|
85 |
private function __construct() {}
|
@@ -89,8 +95,7 @@ class CrayonWP {
|
|
89 |
}
|
90 |
|
91 |
public static function regex_with_id($id) {
|
92 |
-
return '#\[\s*(crayon-'.$id.')\b[^\]]*\
|
93 |
-
//return '#(?<!\$)(?:(?:\[\s*crayon-'.$id.'\b[^\]]*/\s*\])|(?:\[\s*crayon-'.$id.'\b[^\]]*\][\r\n]*?.*?[\r\n]*?\[\s*/\s*crayon\s*\]))(?!\$)#msi';
|
94 |
}
|
95 |
|
96 |
public static function regex_no_capture() {
|
@@ -101,7 +106,7 @@ class CrayonWP {
|
|
101 |
* Adds the actual Crayon instance, should only be called by add_shortcode()
|
102 |
* $mode can be: 0 = return crayon content, 1 = return only code, 2 = return only plain code
|
103 |
*/
|
104 |
-
|
105 |
CrayonLog::debug('shortcode');
|
106 |
|
107 |
// Load attributes from shortcode
|
@@ -164,6 +169,28 @@ class CrayonWP {
|
|
164 |
return $crayon;
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
/* Uses the main query */
|
168 |
public static function wp() {
|
169 |
CrayonLog::debug('wp (global)');
|
@@ -203,14 +230,10 @@ class CrayonWP {
|
|
203 |
$wp_content = preg_replace_callback('#(?<!\$)\[\s*plain\s*\](.*?)\[\s*/\s*plain\s*\]#msi', 'CrayonFormatter::plain_code', $wp_content);
|
204 |
}
|
205 |
|
206 |
-
// Convert `` backquote tags into <code></code>, if needed
|
207 |
-
if (CrayonGlobalSettings::val(CrayonSettings::BACKQUOTE)) {
|
208 |
-
$wp_content = preg_replace('#(?<!\\\\)`([^`]*)`#msi', '<code>$1</code>', $wp_content);
|
209 |
-
}
|
210 |
-
|
211 |
// Add IDs to the Crayons
|
212 |
CrayonLog::debug('capture adding id ' . $wp_id . ' , now has len ' . strlen($wp_content));
|
213 |
$wp_content = preg_replace_callback(self::REGEX_ID, 'CrayonWP::add_crayon_id', $wp_content);
|
|
|
214 |
CrayonLog::debug('capture added id ' . $wp_id . ' : ' . strlen($wp_content));
|
215 |
|
216 |
// Only include if a post exists with Crayon tag
|
@@ -303,17 +326,20 @@ class CrayonWP {
|
|
303 |
$id = !empty($open_ids[$i]) ? $open_ids[$i] : $closed_ids[$i];
|
304 |
$code = self::crayon_remove_ignore($contents[$i]);
|
305 |
$capture['capture'][$id] = array('post_id'=>$wp_id, 'atts'=>$atts_array, 'code'=>$code);
|
306 |
-
|
307 |
CrayonLog::debug('capture finished for post id ' . $wp_id . ' crayon-id ' . $id . ' atts: ' . count($atts_array) . ' code: ' . strlen($code));
|
308 |
-
|
309 |
$is_inline = isset($atts_array['inline']) && CrayonUtil::str_to_bool($atts_array['inline'], FALSE) ? '-i' : '';
|
310 |
$wp_content = str_replace($full_matches[$i], '[crayon-'.$id.$is_inline.'/]', $wp_content);
|
311 |
}
|
312 |
|
313 |
}
|
314 |
|
315 |
-
|
|
|
|
|
|
|
|
|
316 |
|
|
|
317 |
return $capture;
|
318 |
}
|
319 |
|
@@ -355,6 +381,7 @@ class CrayonWP {
|
|
355 |
}
|
356 |
// Capture post Crayons
|
357 |
$captures = self::capture_crayons($post->ID, $post->post_content);
|
|
|
358 |
// XXX Careful not to undo changes by other plugins
|
359 |
// XXX Must replace to remove $ for ignored Crayons
|
360 |
$post->post_content = $captures['content'];
|
@@ -379,8 +406,6 @@ class CrayonWP {
|
|
379 |
// Capture comment Crayons, decode their contents if decode not specified
|
380 |
$captures = self::capture_crayons($comment->comment_ID, $comment->comment_content, array(CrayonSettings::DECODE => TRUE));
|
381 |
self::$comment_captures[$id_str] = $captures['content'];
|
382 |
-
// $comment->comment_content = $captures['content']; // XXX testing!
|
383 |
-
// var_dump($comment->comment_content); exit;
|
384 |
if ($captures['has_captured'] === TRUE) {
|
385 |
$enqueue = TRUE;
|
386 |
self::$comment_queue[$id_str] = array();
|
@@ -461,7 +486,7 @@ class CrayonWP {
|
|
461 |
|
462 |
// Add Crayon into the_content
|
463 |
public static function the_content($the_content) {
|
464 |
-
CrayonLog::debug('the_content');
|
465 |
|
466 |
// Some themes make redundant queries and don't need extra work...
|
467 |
if (strlen($the_content) == 0) {
|
@@ -475,7 +500,9 @@ class CrayonWP {
|
|
475 |
$post_id = strval($post->ID);
|
476 |
|
477 |
if (self::$is_excerpt) {
|
|
|
478 |
if (CrayonGlobalSettings::val(CrayonSettings::EXCERPT_STRIP)) {
|
|
|
479 |
// Remove Crayon from content if we are displaying an excerpt
|
480 |
$the_content = preg_replace(self::REGEX_WITH_ID, '', $the_content);
|
481 |
}
|
@@ -487,6 +514,7 @@ class CrayonWP {
|
|
487 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
488 |
// XXX We want the plain post content, no formatting
|
489 |
$the_content_original = $the_content;
|
|
|
490 |
// Replacing may cause <p> tags to become disjoint with a <div> inside them, close and reopen them if needed
|
491 |
$the_content = preg_replace_callback('#' . self::REGEX_BETWEEN_PARAGRAPH_SIMPLE . '#msi', 'CrayonWP::add_paragraphs', $the_content);
|
492 |
// Loop through Crayons
|
@@ -561,11 +589,7 @@ class CrayonWP {
|
|
561 |
|
562 |
// Remove Crayons from the_excerpt
|
563 |
public static function the_excerpt($the_excerpt) {
|
564 |
-
// var_dump("<i>".htmlentities($the_excerpt)."</i>");
|
565 |
CrayonLog::debug('excerpt');
|
566 |
-
// return $the_excerpt;
|
567 |
-
// return '_';
|
568 |
-
// self::$is_excerpt = TRUE;
|
569 |
global $post;
|
570 |
if (!empty($post->post_excerpt)) {
|
571 |
// Use custom excerpt if defined
|
@@ -574,8 +598,6 @@ class CrayonWP {
|
|
574 |
// Pass wp_trim_excerpt('') to gen from content (and remove [crayons])
|
575 |
$the_excerpt = wpautop(wp_trim_excerpt(''));
|
576 |
}
|
577 |
-
// $the_excerpt = wpautop(wp_trim_excerpt(''));
|
578 |
-
// self::$is_excerpt = FALSE;
|
579 |
// XXX Returning "" may cause it to default to full contents...
|
580 |
return $the_excerpt . ' ';
|
581 |
}
|
@@ -646,8 +668,6 @@ class CrayonWP {
|
|
646 |
}
|
647 |
$ignore_flag_regex = preg_quote($ignore_flag);
|
648 |
|
649 |
-
// $the_content = str_ireplace(array('$[crayon', 'crayon]$'), array('[crayon', 'crayon]'), $the_content);
|
650 |
-
|
651 |
$the_content = preg_replace('#'.$ignore_flag_regex.'(\s*\[\s*crayon)#msi', '$1', $the_content);
|
652 |
$the_content = preg_replace('#(crayon\s*\])\s*\$#msi', '$1', $the_content);
|
653 |
|
@@ -661,7 +681,7 @@ class CrayonWP {
|
|
661 |
CrayonGlobalSettings::val(CrayonSettings::INLINE_TAG)) {
|
662 |
self::init_tags_regex();
|
663 |
$the_content = preg_replace('#'.$ignore_flag_regex.'\s*([\[\{])\s*('. self::$alias_regex .')#', '$1$2', $the_content);
|
664 |
-
$the_content = preg_replace('#('. self::$alias_regex .')\s*([\
|
665 |
}
|
666 |
if (CrayonGlobalSettings::val(CrayonSettings::BACKQUOTE)) {
|
667 |
$the_content = str_ireplace('\\`', '`', $the_content);
|
@@ -782,26 +802,28 @@ class CrayonWP {
|
|
782 |
}
|
783 |
|
784 |
public static function wp_load_path() {
|
785 |
-
$wp_root_path =
|
786 |
-
return $wp_root_path . 'wp-load.php';
|
787 |
}
|
788 |
|
789 |
public static function pre_excerpt($e) {
|
|
|
790 |
self::$is_excerpt = TRUE;
|
791 |
return $e;
|
792 |
}
|
793 |
|
794 |
public static function post_excerpt($e) {
|
|
|
795 |
self::$is_excerpt = FALSE;
|
796 |
$e = self::the_content($e);
|
797 |
return $e;
|
798 |
}
|
799 |
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
|
806 |
}
|
807 |
|
@@ -832,16 +854,12 @@ if (defined('ABSPATH')) {
|
|
832 |
add_filter('comment_text', 'CrayonWP::comment_text', 100);
|
833 |
}
|
834 |
|
835 |
-
// We want to allow others to define excerpt length etc later, so low priority
|
836 |
-
// add_filter('the_excerpt', 'CrayonWP::the_excerpt', 1);
|
837 |
-
|
838 |
// This ensures Crayons are not formatted by WP filters. Other plugins should specify priorities between 1 and 100.
|
839 |
add_filter('get_the_excerpt', 'CrayonWP::pre_excerpt', 1);
|
|
|
840 |
add_filter('the_excerpt', 'CrayonWP::post_excerpt', 100);
|
841 |
|
842 |
-
|
843 |
-
add_action('template_redirect', 'CrayonWP::wp_head');
|
844 |
-
|
845 |
} else {
|
846 |
// For marking a post as containing a Crayon
|
847 |
add_action('save_post', 'CrayonWP::save_post', 10, 2);
|
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.7
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
Text Domain: crayon-syntax-highlighter
|
76 |
|
77 |
const REGEX_ID = '#(?<!\$)\[\s*crayon#mi';
|
78 |
//const REGEX_WITH_ID = '#(\[\s*crayon-\w+)\b([^\]]*["\'])(\s*/?\s*\])#mi';
|
79 |
+
const REGEX_WITH_ID = '#\[\s*(crayon-\w+)\b[^\]]*\]#mi';
|
80 |
|
81 |
const MODE_NORMAL = 0, MODE_JUST_CODE = 1, MODE_PLAIN_CODE = 2;
|
82 |
|
83 |
+
// Public Methods =========================================================
|
84 |
+
|
85 |
+
// public static function post_captures() {
|
86 |
+
// return self::$post_queue;
|
87 |
+
// }
|
88 |
+
|
89 |
// Methods ================================================================
|
90 |
|
91 |
private function __construct() {}
|
95 |
}
|
96 |
|
97 |
public static function regex_with_id($id) {
|
98 |
+
return '#\[\s*(crayon-'.$id.')\b[^\]]*\]#mi';
|
|
|
99 |
}
|
100 |
|
101 |
public static function regex_no_capture() {
|
106 |
* Adds the actual Crayon instance, should only be called by add_shortcode()
|
107 |
* $mode can be: 0 = return crayon content, 1 = return only code, 2 = return only plain code
|
108 |
*/
|
109 |
+
public static function shortcode($atts, $content = NULL, $id = NULL) {
|
110 |
CrayonLog::debug('shortcode');
|
111 |
|
112 |
// Load attributes from shortcode
|
169 |
return $crayon;
|
170 |
}
|
171 |
|
172 |
+
/* For manually highlighting code, useful for other PHP contexts */
|
173 |
+
public static function highlight($code) {
|
174 |
+
$crayon_str = '';
|
175 |
+
|
176 |
+
$captures = CrayonWP::capture_crayons(0, $code);
|
177 |
+
$captures = $captures['capture'];
|
178 |
+
foreach ($captures as $capture) {
|
179 |
+
$id = $capture['id'];
|
180 |
+
$atts = $capture['atts'];
|
181 |
+
$no_enqueue = array(
|
182 |
+
CrayonSettings::ENQUEUE_THEMES => FALSE,
|
183 |
+
CrayonSettings::ENQUEUE_FONTS => FALSE);
|
184 |
+
$atts = array_merge($atts, $no_enqueue);
|
185 |
+
$content = $capture['code'];
|
186 |
+
$crayon = CrayonWP::shortcode($atts, $content, $id);
|
187 |
+
$crayon_formatted = $crayon->output(TRUE, FALSE);
|
188 |
+
$crayon_str .= $crayon_formatted;
|
189 |
+
}
|
190 |
+
|
191 |
+
return $crayon_str;
|
192 |
+
}
|
193 |
+
|
194 |
/* Uses the main query */
|
195 |
public static function wp() {
|
196 |
CrayonLog::debug('wp (global)');
|
230 |
$wp_content = preg_replace_callback('#(?<!\$)\[\s*plain\s*\](.*?)\[\s*/\s*plain\s*\]#msi', 'CrayonFormatter::plain_code', $wp_content);
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
233 |
// Add IDs to the Crayons
|
234 |
CrayonLog::debug('capture adding id ' . $wp_id . ' , now has len ' . strlen($wp_content));
|
235 |
$wp_content = preg_replace_callback(self::REGEX_ID, 'CrayonWP::add_crayon_id', $wp_content);
|
236 |
+
|
237 |
CrayonLog::debug('capture added id ' . $wp_id . ' : ' . strlen($wp_content));
|
238 |
|
239 |
// Only include if a post exists with Crayon tag
|
326 |
$id = !empty($open_ids[$i]) ? $open_ids[$i] : $closed_ids[$i];
|
327 |
$code = self::crayon_remove_ignore($contents[$i]);
|
328 |
$capture['capture'][$id] = array('post_id'=>$wp_id, 'atts'=>$atts_array, 'code'=>$code);
|
|
|
329 |
CrayonLog::debug('capture finished for post id ' . $wp_id . ' crayon-id ' . $id . ' atts: ' . count($atts_array) . ' code: ' . strlen($code));
|
|
|
330 |
$is_inline = isset($atts_array['inline']) && CrayonUtil::str_to_bool($atts_array['inline'], FALSE) ? '-i' : '';
|
331 |
$wp_content = str_replace($full_matches[$i], '[crayon-'.$id.$is_inline.'/]', $wp_content);
|
332 |
}
|
333 |
|
334 |
}
|
335 |
|
336 |
+
// Convert `` backquote tags into <code></code>, if needed
|
337 |
+
// XXX Some code may contain `` so must do it after all Crayons are captured
|
338 |
+
if (CrayonGlobalSettings::val(CrayonSettings::BACKQUOTE)) {
|
339 |
+
$wp_content = preg_replace('#(?<!\\\\)`([^`]*)`#msi', '<code>$1</code>', $wp_content);
|
340 |
+
}
|
341 |
|
342 |
+
$capture['content'] = $wp_content;
|
343 |
return $capture;
|
344 |
}
|
345 |
|
381 |
}
|
382 |
// Capture post Crayons
|
383 |
$captures = self::capture_crayons($post->ID, $post->post_content);
|
384 |
+
|
385 |
// XXX Careful not to undo changes by other plugins
|
386 |
// XXX Must replace to remove $ for ignored Crayons
|
387 |
$post->post_content = $captures['content'];
|
406 |
// Capture comment Crayons, decode their contents if decode not specified
|
407 |
$captures = self::capture_crayons($comment->comment_ID, $comment->comment_content, array(CrayonSettings::DECODE => TRUE));
|
408 |
self::$comment_captures[$id_str] = $captures['content'];
|
|
|
|
|
409 |
if ($captures['has_captured'] === TRUE) {
|
410 |
$enqueue = TRUE;
|
411 |
self::$comment_queue[$id_str] = array();
|
486 |
|
487 |
// Add Crayon into the_content
|
488 |
public static function the_content($the_content) {
|
489 |
+
CrayonLog::debug('the_content');
|
490 |
|
491 |
// Some themes make redundant queries and don't need extra work...
|
492 |
if (strlen($the_content) == 0) {
|
500 |
$post_id = strval($post->ID);
|
501 |
|
502 |
if (self::$is_excerpt) {
|
503 |
+
CrayonLog::debug('excerpt');
|
504 |
if (CrayonGlobalSettings::val(CrayonSettings::EXCERPT_STRIP)) {
|
505 |
+
CrayonLog::debug('excerpt strip');
|
506 |
// Remove Crayon from content if we are displaying an excerpt
|
507 |
$the_content = preg_replace(self::REGEX_WITH_ID, '', $the_content);
|
508 |
}
|
514 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
515 |
// XXX We want the plain post content, no formatting
|
516 |
$the_content_original = $the_content;
|
517 |
+
|
518 |
// Replacing may cause <p> tags to become disjoint with a <div> inside them, close and reopen them if needed
|
519 |
$the_content = preg_replace_callback('#' . self::REGEX_BETWEEN_PARAGRAPH_SIMPLE . '#msi', 'CrayonWP::add_paragraphs', $the_content);
|
520 |
// Loop through Crayons
|
589 |
|
590 |
// Remove Crayons from the_excerpt
|
591 |
public static function the_excerpt($the_excerpt) {
|
|
|
592 |
CrayonLog::debug('excerpt');
|
|
|
|
|
|
|
593 |
global $post;
|
594 |
if (!empty($post->post_excerpt)) {
|
595 |
// Use custom excerpt if defined
|
598 |
// Pass wp_trim_excerpt('') to gen from content (and remove [crayons])
|
599 |
$the_excerpt = wpautop(wp_trim_excerpt(''));
|
600 |
}
|
|
|
|
|
601 |
// XXX Returning "" may cause it to default to full contents...
|
602 |
return $the_excerpt . ' ';
|
603 |
}
|
668 |
}
|
669 |
$ignore_flag_regex = preg_quote($ignore_flag);
|
670 |
|
|
|
|
|
671 |
$the_content = preg_replace('#'.$ignore_flag_regex.'(\s*\[\s*crayon)#msi', '$1', $the_content);
|
672 |
$the_content = preg_replace('#(crayon\s*\])\s*\$#msi', '$1', $the_content);
|
673 |
|
681 |
CrayonGlobalSettings::val(CrayonSettings::INLINE_TAG)) {
|
682 |
self::init_tags_regex();
|
683 |
$the_content = preg_replace('#'.$ignore_flag_regex.'\s*([\[\{])\s*('. self::$alias_regex .')#', '$1$2', $the_content);
|
684 |
+
$the_content = preg_replace('#('. self::$alias_regex .')\s*([\]\}])\s*'.$ignore_flag_regex.'#', '$1$2', $the_content);
|
685 |
}
|
686 |
if (CrayonGlobalSettings::val(CrayonSettings::BACKQUOTE)) {
|
687 |
$the_content = str_ireplace('\\`', '`', $the_content);
|
802 |
}
|
803 |
|
804 |
public static function wp_load_path() {
|
805 |
+
$wp_root_path = dirname(dirname(dirname(CRAYON_ROOT_PATH)));
|
806 |
+
return $wp_root_path . '/wp-load.php';
|
807 |
}
|
808 |
|
809 |
public static function pre_excerpt($e) {
|
810 |
+
CrayonLog::debug('pre_excerpt');
|
811 |
self::$is_excerpt = TRUE;
|
812 |
return $e;
|
813 |
}
|
814 |
|
815 |
public static function post_excerpt($e) {
|
816 |
+
CrayonLog::debug('post_excerpt');
|
817 |
self::$is_excerpt = FALSE;
|
818 |
$e = self::the_content($e);
|
819 |
return $e;
|
820 |
}
|
821 |
|
822 |
+
public static function post_get_excerpt($e) {
|
823 |
+
CrayonLog::debug('post_get_excerpt');
|
824 |
+
self::$is_excerpt = FALSE;
|
825 |
+
return $e;
|
826 |
+
}
|
827 |
|
828 |
}
|
829 |
|
854 |
add_filter('comment_text', 'CrayonWP::comment_text', 100);
|
855 |
}
|
856 |
|
|
|
|
|
|
|
857 |
// This ensures Crayons are not formatted by WP filters. Other plugins should specify priorities between 1 and 100.
|
858 |
add_filter('get_the_excerpt', 'CrayonWP::pre_excerpt', 1);
|
859 |
+
add_filter('get_the_excerpt', 'CrayonWP::post_get_excerpt', 100);
|
860 |
add_filter('the_excerpt', 'CrayonWP::post_excerpt', 100);
|
861 |
|
862 |
+
add_action('template_redirect', 'CrayonWP::wp_head');
|
|
|
|
|
863 |
} else {
|
864 |
// For marking a post as containing a Crayon
|
865 |
add_action('save_post', 'CrayonWP::save_post', 10, 2);
|
css/style.css
CHANGED
@@ -26,6 +26,7 @@ coloring etc.
|
|
26 |
text-align: left;
|
27 |
}
|
28 |
|
|
|
29 |
.crayon-syntax .crayon-main,
|
30 |
.crayon-syntax .crayon-toolbar,
|
31 |
.crayon-syntax .crayon-info,
|
26 |
text-align: left;
|
27 |
}
|
28 |
|
29 |
+
.crayon-syntax,
|
30 |
.crayon-syntax .crayon-main,
|
31 |
.crayon-syntax .crayon-toolbar,
|
32 |
.crayon-syntax .crayon-info,
|
global.php
CHANGED
@@ -5,8 +5,8 @@
|
|
5 |
define('CRAYON_DEBUG', FALSE);
|
6 |
|
7 |
// TODO remove once done
|
8 |
-
define('CRAYON_TAG_EDITOR',
|
9 |
-
define('CRAYON_THEME_EDITOR',
|
10 |
|
11 |
// Constants
|
12 |
|
5 |
define('CRAYON_DEBUG', FALSE);
|
6 |
|
7 |
// TODO remove once done
|
8 |
+
define('CRAYON_TAG_EDITOR', TRUE);
|
9 |
+
define('CRAYON_THEME_EDITOR', FALSE);
|
10 |
|
11 |
// Constants
|
12 |
|
readme.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
=== Crayon Syntax Highlighter ===
|
2 |
Contributors: akarmenia
|
3 |
-
Donate link:
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.2
|
@@ -15,7 +15,7 @@ It can highlight from a URL, a local file or Wordpress post text. Crayon makes i
|
|
15 |
custom language elements with regular expressions.
|
16 |
It also supports some neat features like:
|
17 |
|
18 |
-
* <a href="http://
|
19 |
* Toggled plain code
|
20 |
* Toggled line numbers
|
21 |
* Copy/paste code
|
@@ -23,12 +23,12 @@ It also supports some neat features like:
|
|
23 |
* Remote request caching
|
24 |
* <a href="http://ak.net84.net/projects/mixed-language-highlighting-in-crayon/" target="_blank">Mixed Language Highlighting</a> in a single Crayon
|
25 |
* <a href="http://ak.net84.net/projects/mini-tags-in-crayon/" target="_blank">Mini Tags</a> like [php][/php]
|
26 |
-
* <a href="http://
|
27 |
* Crayons in comments
|
28 |
* `Backquotes` become <code>
|
29 |
* <pre> tag support, option to use <code>setting-value</code> in the class attribute
|
30 |
* Valid HTML 5 markup
|
31 |
-
* <a href="http://
|
32 |
* Mobile/touchscreen device detection
|
33 |
* Mouse event interaction (showing plain code on double click, toolbar on mouseover)
|
34 |
* Tab sizes
|
@@ -45,7 +45,7 @@ It also supports some neat features like:
|
|
45 |
|
46 |
**Links**
|
47 |
|
48 |
-
* <a href="http://
|
49 |
* <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/" target="_blank">Short How-To</a>
|
50 |
|
51 |
**Contributions**
|
@@ -55,7 +55,7 @@ There are many ways you can help!
|
|
55 |
* Make a Theme and share
|
56 |
* Add support for your favourite <a href="http://ak.net84.net/projects/crayon-language-file-specification/" target="_blank">Language</a>
|
57 |
* Write a post about your pastel experiences and share
|
58 |
-
* <a href="
|
59 |
|
60 |
**Supported Languages**
|
61 |
|
@@ -117,6 +117,10 @@ These are helpful for discovering new features.
|
|
117 |
|
118 |
A handful of articles from others written about Crayon, thanks guys!
|
119 |
|
|
|
|
|
|
|
|
|
120 |
* <a href="http://www.doitwithwp.com/displaying-code-in-wordpress-with-crayon-syntax-highlighter/" target="_blank">Displaying Code in WordPress with Crayon </a>
|
121 |
* <a href="http://blog.boxedpages.net/2012/03/15/abap-syntaxhighlighting-in-wordpress/" target="_blank">ABAP Syntax Highlighting in WordPress (German)</a>
|
122 |
* <a href="http://jstips.org/2012/04/23/crayon-syntax-highlighter-plugin/" target="_blank">Crayon Syntax Highlighter plugin</a>
|
@@ -127,8 +131,9 @@ A handful of articles from others written about Crayon, thanks guys!
|
|
127 |
* http://www.wplover.com/2155/crayon-syntax-highlighter-plugin/
|
128 |
* http://www.htmlandphp.com/scripts/crayon-syntax-highlighter.html
|
129 |
|
130 |
-
**
|
131 |
|
|
|
132 |
* Theme Editor
|
133 |
|
134 |
== Installation ==
|
@@ -143,7 +148,7 @@ A handful of articles from others written about Crayon, thanks guys!
|
|
143 |
|
144 |
= How do I use the Tag Editor? =
|
145 |
|
146 |
-
The <a href="http://
|
147 |
|
148 |
= How do I use it manually? =
|
149 |
|
@@ -169,7 +174,15 @@ Please see the <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/"
|
|
169 |
|
170 |
= Why are the controls not working? =
|
171 |
|
172 |
-
Make sure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
= Support =
|
175 |
|
@@ -184,6 +197,20 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
184 |
|
185 |
== Changelog ==
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
= 1.9.4 =
|
188 |
* Added /util/external_use.php for an example of how to use Crayon in other PHP environments.
|
189 |
* Fixed issues with the excerpt, now Crayons are not stripped out by default, can be changed in Settings > Misc.
|
@@ -334,7 +361,7 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
334 |
* "Always display scrollbars" now a checkbox
|
335 |
|
336 |
= 1.7.19 =
|
337 |
-
* Fixed issue with Crayons failing to load on pages with templates containing The Loop. http://
|
338 |
* Objective-C operators improved
|
339 |
|
340 |
= 1.7.18 =
|
@@ -402,7 +429,7 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
402 |
* Added namespacing to crayon.js to prevent conflicts
|
403 |
|
404 |
= 1.7.3 =
|
405 |
-
* Added Mini Tags and Plain Tags into Crayon. http://
|
406 |
* Fixed a bug causing RSS feeds to contain malformed HTML of Crayons, now it shows plain code with correct indentations. Thanks to Артём.
|
407 |
* Updated help in Settings and http://ak.net84.net/projects/crayon-syntax-highlighter/
|
408 |
|
@@ -413,7 +440,7 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
413 |
* Renamed Japanese GNU language code from ja_JP to ja.
|
414 |
|
415 |
= 1.7.0 =
|
416 |
-
* Added the ability to highlight multiple languages in a single Crayon! http://
|
417 |
* A bunch of language improvements, a few CSS improvements, etc.
|
418 |
|
419 |
= 1.6.6 =
|
@@ -591,6 +618,10 @@ Make sure to upgrade to the latest release when possible to ensure you avoid bug
|
|
591 |
|
592 |
Thanks to all those who donate to my project, your support keeps the Crayons going!
|
593 |
|
|
|
|
|
|
|
|
|
594 |
* Christy Wiggins, (http://www.jinxyisms.com/), USA
|
595 |
* eSnipe, Inc. (http://esnipe.com/), USA (again!)
|
596 |
* Aliseya Wright, (http://blog.xoxothemes.com/), USA
|
1 |
=== Crayon Syntax Highlighter ===
|
2 |
Contributors: akarmenia
|
3 |
+
Donate link: https://www.paypal.com/au/cgi-bin/webscr?cmd=_flow&SESSION=PPqWIQJ0gEZp4pVGNnYzhcwFGvx3MGwD95tvUcZgeYlHIEjBS7x6QHG34B4&dispatch=5885d80a13c0db1f8e263663d3faee8d0288a7fd2903afb85a5540fd44243d03
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.2
|
15 |
custom language elements with regular expressions.
|
16 |
It also supports some neat features like:
|
17 |
|
18 |
+
* <a href="http://ak.net84.net/projects/crayon-tag-editor/" target="_blank">Tag Editor</a> in both Visual & HTML editors
|
19 |
* Toggled plain code
|
20 |
* Toggled line numbers
|
21 |
* Copy/paste code
|
23 |
* Remote request caching
|
24 |
* <a href="http://ak.net84.net/projects/mixed-language-highlighting-in-crayon/" target="_blank">Mixed Language Highlighting</a> in a single Crayon
|
25 |
* <a href="http://ak.net84.net/projects/mini-tags-in-crayon/" target="_blank">Mini Tags</a> like [php][/php]
|
26 |
+
* <a href="http://ak.net84.net/crayon/inline-crayons/" target="_blank">Inline Tags</a> floating in sentences
|
27 |
* Crayons in comments
|
28 |
* `Backquotes` become <code>
|
29 |
* <pre> tag support, option to use <code>setting-value</code> in the class attribute
|
30 |
* Valid HTML 5 markup
|
31 |
+
* <a href="http://ak.net84.net/projects/crayon-tag-editor/" target="_blank">Visual & HTML editor compatible</a>
|
32 |
* Mobile/touchscreen device detection
|
33 |
* Mouse event interaction (showing plain code on double click, toolbar on mouseover)
|
34 |
* Tab sizes
|
45 |
|
46 |
**Links**
|
47 |
|
48 |
+
* <a href="http://aksandbox.webege.com/?p=1" target="_blank">Live Demo</a>
|
49 |
* <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/" target="_blank">Short How-To</a>
|
50 |
|
51 |
**Contributions**
|
55 |
* Make a Theme and share
|
56 |
* Add support for your favourite <a href="http://ak.net84.net/projects/crayon-language-file-specification/" target="_blank">Language</a>
|
57 |
* Write a post about your pastel experiences and share
|
58 |
+
* <a href="https://www.paypal.com/au/cgi-bin/webscr?cmd=_flow&SESSION=PPqWIQJ0gEZp4pVGNnYzhcwFGvx3MGwD95tvUcZgeYlHIEjBS7x6QHG34B4&dispatch=5885d80a13c0db1f8e263663d3faee8d0288a7fd2903afb85a5540fd44243d03" target="_blank">Donate</a> to the project
|
59 |
|
60 |
**Supported Languages**
|
61 |
|
117 |
|
118 |
A handful of articles from others written about Crayon, thanks guys!
|
119 |
|
120 |
+
|
121 |
+
* <a href="http://selfpwnt.com/crayon-syntax-highlighter-and-its-studly-author/" target="_blank">Crayon Syntax Highlighter (and its studly author)</a>
|
122 |
+
* <a href="http://bit51.com/add-code-to-your-wordpress-posts-with-crayon-syntax-highlighter/" target="_blank">Add Code To Your WordPress Posts With Crayon Syntax Highlighter</a>
|
123 |
+
* <a href="http://www.wpsquare.com/syntax-highlighter-wordpress-plugins/" target="_blank">15 Best Syntax Highlighter WordPress Plugins</a>
|
124 |
* <a href="http://www.doitwithwp.com/displaying-code-in-wordpress-with-crayon-syntax-highlighter/" target="_blank">Displaying Code in WordPress with Crayon </a>
|
125 |
* <a href="http://blog.boxedpages.net/2012/03/15/abap-syntaxhighlighting-in-wordpress/" target="_blank">ABAP Syntax Highlighting in WordPress (German)</a>
|
126 |
* <a href="http://jstips.org/2012/04/23/crayon-syntax-highlighter-plugin/" target="_blank">Crayon Syntax Highlighter plugin</a>
|
131 |
* http://www.wplover.com/2155/crayon-syntax-highlighter-plugin/
|
132 |
* http://www.htmlandphp.com/scripts/crayon-syntax-highlighter.html
|
133 |
|
134 |
+
**Future Development**
|
135 |
|
136 |
+
* Performance, minimised resources
|
137 |
* Theme Editor
|
138 |
|
139 |
== Installation ==
|
148 |
|
149 |
= How do I use the Tag Editor? =
|
150 |
|
151 |
+
The <a href="http://ak.net84.net/projects/crayon-tag-editor/" target="_blank">Tag Editor</a> provides a dialog box to add Crayons easily.
|
152 |
|
153 |
= How do I use it manually? =
|
154 |
|
174 |
|
175 |
= Why are the controls not working? =
|
176 |
|
177 |
+
Make sure jQuery is included in your theme ONCE and before all its dependents (see Installation).
|
178 |
+
|
179 |
+
= Why am I only seeing [crayon-3ffr7fa34a321/]? =
|
180 |
+
|
181 |
+
Your theme is being naughty. Find where it prints the content/excerpt on that page in the PHP and make sure to add this line before printing:
|
182 |
+
|
183 |
+
$output = apply_filters('the_content', $output);
|
184 |
+
|
185 |
+
This ensures that the content can be filtered by plugins, such as Crayon. Otherwise, Crayon detects and creates the code but can't replace those funny looking tags in the content.
|
186 |
|
187 |
= Support =
|
188 |
|
197 |
|
198 |
== Changelog ==
|
199 |
|
200 |
+
= 1.9.7 =
|
201 |
+
* Fixed a crucial but hard to spot bug causing Crayon code to break by incorrectly handling ignored Crayons
|
202 |
+
* Added functions to generate Crayons when given Crayon tags in strings like the post content
|
203 |
+
* Added width:100%; so CSS float works
|
204 |
+
* Removed bit.ly links from this readme
|
205 |
+
|
206 |
+
= 1.9.6 =
|
207 |
+
* Fixed a bug causing wordpress wp_content path customisations to break the tag editor and live preview
|
208 |
+
* Fixed a bug with marked lines using ranges
|
209 |
+
|
210 |
+
= 1.9.5 =
|
211 |
+
* Fixed a bug that prevent Crayons from being captured internally, only affected on certain themes
|
212 |
+
* Fixed a bug causing backquotes being changed to code within Crayon code
|
213 |
+
|
214 |
= 1.9.4 =
|
215 |
* Added /util/external_use.php for an example of how to use Crayon in other PHP environments.
|
216 |
* Fixed issues with the excerpt, now Crayons are not stripped out by default, can be changed in Settings > Misc.
|
361 |
* "Always display scrollbars" now a checkbox
|
362 |
|
363 |
= 1.7.19 =
|
364 |
+
* Fixed issue with Crayons failing to load on pages with templates containing The Loop. http://ak.net84.net/crayon/failing-to-load-crayons-on-pages/
|
365 |
* Objective-C operators improved
|
366 |
|
367 |
= 1.7.18 =
|
429 |
* Added namespacing to crayon.js to prevent conflicts
|
430 |
|
431 |
= 1.7.3 =
|
432 |
+
* Added Mini Tags and Plain Tags into Crayon. http://ak.net84.net/projects/mini-tags-in-crayon/
|
433 |
* Fixed a bug causing RSS feeds to contain malformed HTML of Crayons, now it shows plain code with correct indentations. Thanks to Артём.
|
434 |
* Updated help in Settings and http://ak.net84.net/projects/crayon-syntax-highlighter/
|
435 |
|
440 |
* Renamed Japanese GNU language code from ja_JP to ja.
|
441 |
|
442 |
= 1.7.0 =
|
443 |
+
* Added the ability to highlight multiple languages in a single Crayon! http://ak.net84.net/projects/mixed-language-highlighting-in-crayon/
|
444 |
* A bunch of language improvements, a few CSS improvements, etc.
|
445 |
|
446 |
= 1.6.6 =
|
618 |
|
619 |
Thanks to all those who donate to my project, your support keeps the Crayons going!
|
620 |
|
621 |
+
* Oldrich Strachota, (http://www.strachota.net/), Czech Republic
|
622 |
+
* Dividend Ninja, (http://dividendninja.com/), Canada
|
623 |
+
* Chris Wiegman, (http://bit51.com/), USA
|
624 |
+
* Sven Meier, (http://www.codesix.net/), Germany
|
625 |
* Christy Wiggins, (http://www.jinxyisms.com/), USA
|
626 |
* eSnipe, Inc. (http://esnipe.com/), USA (again!)
|
627 |
* Aliseya Wright, (http://blog.xoxothemes.com/), USA
|