Version Description
- Recommended upgrade for everyone.
- Major bug fix thanks to twitter.com/42dotno and twitter.com/eriras
- Fixed a bug causing attributes using single quotes to be undetected
- Fixed a bug causing code with dollar signs followed by numbers to be detected as backreferences and replace itself!
- Fixed a bug causing formatting to be totally disregarded.
- Fixed the <!--more--> tag in post_content and the_excerpt by placing crayon detection after all other formatting has taken place
- Added copy and paste, didn't use flash, selects text and asks user to copy (more elegant until they sort out clipboard access)
- Added shell script to languages - use with lang='sh'
- Removed certain usage of heredocs and replaced with string concatenation
- Added 'then' to default statements
- Cleaned up processing of post_queue used for Crayon detection and the_excerpt
- Added focus to plain text to allow easier copy-paste
Download this release
Release Info
Developer | akarmenia |
Plugin | Crayon Syntax Highlighter |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.3.0
- crayon_formatter.class.php +34 -39
- crayon_settings.class.php +3 -1
- crayon_settings_wp.class.php +21 -20
- crayon_wp.class.php +18 -21
- css/style.css +30 -1
- js/crayon.js +134 -39
- js/crayon_admin.js +11 -0
- langs/default/statement.txt +1 -0
- langs/sh/reserved.txt +158 -0
- langs/sh/sh.txt +20 -0
- langs/sh/statement.txt +5 -0
- readme.txt +45 -31
- themes/classic/classic.css +10 -1
- themes/twilight/twilight.css +10 -1
- util/crayon_util.class.php +24 -0
- util/preview.php +2 -2
crayon_formatter.class.php
CHANGED
@@ -185,10 +185,13 @@ class CrayonFormatter {
|
|
185 |
$tab = $hl->setting_val(CrayonSettings::TAB_SIZE);
|
186 |
// TODO doesn't seem to work at the moment
|
187 |
$plain_style = "-moz-tab-size:$tab; -o-tab-size:$tab; -webkit-tab-size:$tab; tab-size:$tab;";
|
188 |
-
$
|
|
|
189 |
$print_plain_button = '<a href="#" class="crayon-plain-button crayon-button" title="Toggle Plain Code" onclick="toggle_plain(\'' . $uid . '\'); return false;"></a>';
|
|
|
|
|
190 |
} else {
|
191 |
-
$print_plain = $plain_settings = $print_plain_button = '';
|
192 |
}
|
193 |
if ($hl->setting_val(CrayonSettings::NUMS_TOGGLE)) {
|
194 |
$print_nums_button = '<a href="#" class="crayon-nums-button crayon-button" title="Toggle Line Numbers" onclick="toggle_nums(\'' . $uid . '\'); return false;"></a>';
|
@@ -197,17 +200,13 @@ class CrayonFormatter {
|
|
197 |
}
|
198 |
/* The table is rendered invisible by CSS and enabled with JS when asked to. If JS
|
199 |
is not enabled or fails, the toolbar won't work so there is no point to display it. */
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
<div class="crayon-tools">
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
</div>
|
208 |
-
</div>
|
209 |
-
{$print_plain}
|
210 |
-
EOT;
|
211 |
} else {
|
212 |
$toolbar = $plain_settings = '';
|
213 |
}
|
@@ -328,39 +327,35 @@ EOT;
|
|
328 |
}
|
329 |
$code_style .= $clear_style;
|
330 |
|
|
|
|
|
|
|
331 |
if ($hl->setting_val(CrayonSettings::FONT_SIZE_ENABLE)) {
|
332 |
// Produce style for individual crayon
|
333 |
-
$output .=
|
334 |
-
<style type="text/css">
|
335 |
-
{$font_style}
|
336 |
-
</style>
|
337 |
-
EOT;
|
338 |
}
|
339 |
|
340 |
// Produce output
|
341 |
-
$output .=
|
342 |
-
<div id="
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
EOT;
|
348 |
|
349 |
if ($print_nums !== FALSE) {
|
350 |
-
$output .=
|
351 |
-
<td class="crayon-nums
|
352 |
-
<div class="crayon-nums-content">
|
353 |
-
</td>
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
</div>
|
363 |
-
EOT;
|
364 |
// Debugging stats
|
365 |
$runtime = $hl->runtime();
|
366 |
if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
|
185 |
$tab = $hl->setting_val(CrayonSettings::TAB_SIZE);
|
186 |
// TODO doesn't seem to work at the moment
|
187 |
$plain_style = "-moz-tab-size:$tab; -o-tab-size:$tab; -webkit-tab-size:$tab; tab-size:$tab;";
|
188 |
+
$readonly = $touch ? '' : 'readonly';
|
189 |
+
$print_plain = '<textarea class="crayon-plain" settings="' . $plain_settings . '" '. $readonly .' wrap="off" style="' . $plain_style .'">' . $hl->code() . '</textarea>';
|
190 |
$print_plain_button = '<a href="#" class="crayon-plain-button crayon-button" title="Toggle Plain Code" onclick="toggle_plain(\'' . $uid . '\'); return false;"></a>';
|
191 |
+
$print_copy_button = !$touch && $hl->setting_val(CrayonSettings::PLAIN) && $hl->setting_val(CrayonSettings::COPY) ?
|
192 |
+
'<a href="#" class="crayon-copy-button crayon-button" title="Copy Plain Code" onclick="copy_plain(\'' . $uid . '\'); return false;"></a>' : '';
|
193 |
} else {
|
194 |
+
$print_plain = $plain_settings = $print_plain_button = $print_copy_button = '';
|
195 |
}
|
196 |
if ($hl->setting_val(CrayonSettings::NUMS_TOGGLE)) {
|
197 |
$print_nums_button = '<a href="#" class="crayon-nums-button crayon-button" title="Toggle Line Numbers" onclick="toggle_nums(\'' . $uid . '\'); return false;"></a>';
|
200 |
}
|
201 |
/* The table is rendered invisible by CSS and enabled with JS when asked to. If JS
|
202 |
is not enabled or fails, the toolbar won't work so there is no point to display it. */
|
203 |
+
|
204 |
+
$toolbar = '
|
205 |
+
<div class="crayon-toolbar" settings="'.$toolbar_settings.'">'.$print_title.'
|
206 |
+
<div class="crayon-tools">'.$print_nums_button.$print_copy_button.$print_plain_button.$print_lang.'</div>
|
207 |
+
</div><div>'.$print_plain.'</div>'.'<div class="crayon-info"></div>';
|
208 |
+
|
209 |
+
|
|
|
|
|
|
|
|
|
210 |
} else {
|
211 |
$toolbar = $plain_settings = '';
|
212 |
}
|
327 |
}
|
328 |
$code_style .= $clear_style;
|
329 |
|
330 |
+
// Determine if operating system is mac
|
331 |
+
$crayon_os = CrayonUtil::is_mac() ? 'mac' : 'pc';
|
332 |
+
|
333 |
if ($hl->setting_val(CrayonSettings::FONT_SIZE_ENABLE)) {
|
334 |
// Produce style for individual crayon
|
335 |
+
$output .= '<style type="text/css">'.$font_style.'</style>';
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
|
338 |
// Produce output
|
339 |
+
$output .= '
|
340 |
+
<div id="'.$uid.'" class="crayon-syntax crayon-theme-'.$theme_id_dashed.$font_id_dashed.'" crayon-os="'.$crayon_os.'" settings="'.$code_settings.'" style="'.$code_style.'">
|
341 |
+
'.$toolbar.'
|
342 |
+
<div class="crayon-main" style="'.$main_style.'">
|
343 |
+
<table class="crayon-table" cellpadding="0" cellspacing="0">
|
344 |
+
<tr class="crayon-row">';
|
|
|
345 |
|
346 |
if ($print_nums !== FALSE) {
|
347 |
+
$output .= '
|
348 |
+
<td class="crayon-nums '.$num_vis.'" settings="'.$num_settings.'">
|
349 |
+
<div class="crayon-nums-content">'.$print_nums.'</div>
|
350 |
+
</td>';
|
351 |
+
}
|
352 |
+
// XXX
|
353 |
+
$output .= '
|
354 |
+
<td class="crayon-code"><div class="crayon-pre">'.$print_code.'</div></td>
|
355 |
+
</tr>
|
356 |
+
</table>
|
357 |
+
</div>
|
358 |
+
</div>';
|
|
|
|
|
359 |
// Debugging stats
|
360 |
$runtime = $hl->runtime();
|
361 |
if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
|
crayon_settings.class.php
CHANGED
@@ -41,6 +41,7 @@ class CrayonSettings {
|
|
41 |
const TOOLBAR_OVERLAY = 'toolbar-overlay';
|
42 |
const TOOLBAR_HIDE = 'toolbar-hide';
|
43 |
const TOOLBAR_DELAY = 'toolbar-delay';
|
|
|
44 |
const SHOW_LANG = 'show-lang';
|
45 |
const SHOW_TITLE = 'show-title';
|
46 |
const STRIPED = 'striped';
|
@@ -116,7 +117,8 @@ class CrayonSettings {
|
|
116 |
new CrayonSetting(self::TOOLBAR, array('On MouseOver', 'Always', 'Never')),
|
117 |
new CrayonSetting(self::TOOLBAR_OVERLAY, TRUE),
|
118 |
new CrayonSetting(self::TOOLBAR_HIDE, TRUE),
|
119 |
-
new CrayonSetting(self::TOOLBAR_DELAY, TRUE),
|
|
|
120 |
new CrayonSetting(self::SHOW_LANG, array('When Found', 'Always', 'Never')),
|
121 |
new CrayonSetting(self::SHOW_TITLE, TRUE),
|
122 |
new CrayonSetting(self::STRIPED, TRUE),
|
41 |
const TOOLBAR_OVERLAY = 'toolbar-overlay';
|
42 |
const TOOLBAR_HIDE = 'toolbar-hide';
|
43 |
const TOOLBAR_DELAY = 'toolbar-delay';
|
44 |
+
const COPY = 'copy';
|
45 |
const SHOW_LANG = 'show-lang';
|
46 |
const SHOW_TITLE = 'show-title';
|
47 |
const STRIPED = 'striped';
|
117 |
new CrayonSetting(self::TOOLBAR, array('On MouseOver', 'Always', 'Never')),
|
118 |
new CrayonSetting(self::TOOLBAR_OVERLAY, TRUE),
|
119 |
new CrayonSetting(self::TOOLBAR_HIDE, TRUE),
|
120 |
+
new CrayonSetting(self::TOOLBAR_DELAY, TRUE),
|
121 |
+
new CrayonSetting(self::COPY, TRUE),
|
122 |
new CrayonSetting(self::SHOW_LANG, array('When Found', 'Always', 'Never')),
|
123 |
new CrayonSetting(self::SHOW_TITLE, TRUE),
|
124 |
new CrayonSetting(self::STRIPED, TRUE),
|
crayon_settings_wp.class.php
CHANGED
@@ -304,12 +304,12 @@ class CrayonSettingsWP {
|
|
304 |
}
|
305 |
$url = plugins_url(CRAYON_AJAX_PHP, __FILE__) . '?' . CrayonSettings::HIDE_HELP . '=1';
|
306 |
$web = $CRAYON_WEBSITE;
|
307 |
-
echo
|
308 |
<div id="crayon-help" class="updated settings-error crayon-help">
|
309 |
-
<span><strong>Howdy, coder!</strong> Thanks for using Crayon. Use <strong>help</strong> on the top of this page to learn how to use the shortcode and basic features, or check out my <a href="#info">Twitter & Email</a>. For online help and info, visit <a target="_blank" href="
|
310 |
-
<a class="crayon-help-close" href="#" url="
|
311 |
</div>
|
312 |
-
|
313 |
}
|
314 |
|
315 |
public static function cont_help($contextual_help, $screen_id, $screen) {
|
@@ -461,6 +461,9 @@ EOT;
|
|
461 |
public static function code() {
|
462 |
self::checkbox(array(CrayonSettings::PLAIN, 'Enable plain code view and display: '), FALSE);
|
463 |
self::dropdown(CrayonSettings::SHOW_PLAIN);
|
|
|
|
|
|
|
464 |
echo 'Display scrollbars (when needed): ';
|
465 |
self::dropdown(CrayonSettings::SCROLL);
|
466 |
echo 'Tab size in spaces: ';
|
@@ -523,22 +526,20 @@ EOT;
|
|
523 |
$developer = '<b>Developer:</b> ' . $CRAYON_AUTHOR;
|
524 |
$links = '<a id="twitter-icon" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
|
525 |
<a id="gmail-icon" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>';
|
526 |
-
echo
|
527 |
-
<table id="crayon-info" border="0">
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
</table>
|
540 |
-
|
541 |
-
EOT;
|
542 |
}
|
543 |
}
|
544 |
// Add the settings menus
|
304 |
}
|
305 |
$url = plugins_url(CRAYON_AJAX_PHP, __FILE__) . '?' . CrayonSettings::HIDE_HELP . '=1';
|
306 |
$web = $CRAYON_WEBSITE;
|
307 |
+
echo '
|
308 |
<div id="crayon-help" class="updated settings-error crayon-help">
|
309 |
+
<span><strong>Howdy, coder!</strong> Thanks for using Crayon. Use <strong>help</strong> on the top of this page to learn how to use the shortcode and basic features, or check out my <a href="#info">Twitter & Email</a>. For online help and info, visit <a target="_blank" href="'.$web,'">here</a>.</span>
|
310 |
+
<a class="crayon-help-close" href="#" url="'.$url.'">X</a>
|
311 |
</div>
|
312 |
+
';
|
313 |
}
|
314 |
|
315 |
public static function cont_help($contextual_help, $screen_id, $screen) {
|
461 |
public static function code() {
|
462 |
self::checkbox(array(CrayonSettings::PLAIN, 'Enable plain code view and display: '), FALSE);
|
463 |
self::dropdown(CrayonSettings::SHOW_PLAIN);
|
464 |
+
echo '<span id="crayon-copy-check">';
|
465 |
+
self::checkbox(array(CrayonSettings::COPY, 'Enable code copy/paste'));
|
466 |
+
echo '</span>';
|
467 |
echo 'Display scrollbars (when needed): ';
|
468 |
self::dropdown(CrayonSettings::SCROLL);
|
469 |
echo 'Tab size in spaces: ';
|
526 |
$developer = '<b>Developer:</b> ' . $CRAYON_AUTHOR;
|
527 |
$links = '<a id="twitter-icon" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
|
528 |
<a id="gmail-icon" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>';
|
529 |
+
echo '
|
530 |
+
<table id="crayon-info" border="0">
|
531 |
+
<tr>
|
532 |
+
<td>'.$version.'</td>
|
533 |
+
<td>'.$date.'</td>
|
534 |
+
</tr>
|
535 |
+
<tr>
|
536 |
+
<td>'.$developer.'</td>
|
537 |
+
<td></td>
|
538 |
+
</tr>
|
539 |
+
<tr>
|
540 |
+
<td colspan="2" style="text-align: centera;">'.$links.'</td>
|
541 |
+
</tr>
|
542 |
+
</table>';
|
|
|
|
|
543 |
}
|
544 |
}
|
545 |
// Add the settings menus
|
crayon_wp.class.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
-
Version: 1.
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
@@ -36,8 +36,8 @@ class CrayonWP {
|
|
36 |
|
37 |
// Associative array, keys are post IDs as strings and values are number of crayons parsed as ints
|
38 |
private static $post_queue = array();
|
39 |
-
//
|
40 |
-
private static $
|
41 |
// Whether we have added styles and scripts
|
42 |
private static $included = FALSE;
|
43 |
|
@@ -67,7 +67,7 @@ class CrayonWP {
|
|
67 |
/**
|
68 |
* Adds the actual Crayon instance, should only be called by add_shortcode()
|
69 |
*/
|
70 |
-
private static function shortcode($atts, $content = NULL) {
|
71 |
CrayonSettingsWP::load_settings(); // Run first to ensure global settings loaded
|
72 |
|
73 |
// Lowercase attributes
|
@@ -77,8 +77,6 @@ class CrayonWP {
|
|
77 |
}
|
78 |
$atts = $lower_atts;
|
79 |
|
80 |
-
//echo count($atts);
|
81 |
-
|
82 |
// Load attributes from shortcode
|
83 |
$allowed_atts = array('url' => NULL, 'lang' => NULL, 'title' => NULL, 'mark' => NULL);
|
84 |
$filtered_atts = shortcode_atts($allowed_atts, $atts);
|
@@ -167,7 +165,7 @@ class CrayonWP {
|
|
167 |
}
|
168 |
|
169 |
// Capture attributes
|
170 |
-
preg_match_all('#([^="\'\s]+)[\t ]*=[\t ]*("|\')([^"]
|
171 |
$atts_array = array();
|
172 |
|
173 |
if ( count($att_matches[0]) != 0 ) {
|
@@ -177,9 +175,10 @@ class CrayonWP {
|
|
177 |
}
|
178 |
|
179 |
// Add array of atts and content to post queue with key as post ID
|
180 |
-
self::$post_queue[strval($post->ID)][] = array('id'=>$post->ID, 'atts'=>$atts_array, '
|
181 |
}
|
182 |
}
|
|
|
183 |
}
|
184 |
|
185 |
if (!is_admin() && $enqueue && !self::$included) {
|
@@ -198,45 +197,43 @@ class CrayonWP {
|
|
198 |
}
|
199 |
|
200 |
// Add Crayon into the_content
|
201 |
-
public static function the_content($the_content) {
|
202 |
global $post;
|
203 |
// Go through queued posts and find crayons
|
204 |
$post_id = strval($post->ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
// Find if this post has Crayons
|
206 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
207 |
// XXX We want the plain post content, no formatting
|
208 |
$the_content_original = $the_content;
|
209 |
-
$the_content = $post->post_content;
|
210 |
// Loop through Crayons
|
211 |
$post_in_queue = self::$post_queue[$post_id];
|
212 |
foreach ($post_in_queue as $p) {
|
213 |
$atts = $p['atts'];
|
214 |
-
$content = $p['
|
215 |
-
|
216 |
-
self::$posts[$post_id] = array('content_raw'=>$post->post_content, 'content'=>$the_content_original);
|
217 |
-
|
218 |
// Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
|
219 |
$content = self::crayon_remove_ignore($content);
|
220 |
// Apply shortcode to the content
|
221 |
$crayon = self::shortcode($atts, $content);
|
222 |
-
$the_content =
|
223 |
}
|
224 |
}
|
225 |
// Remove '$' from $[crayon]...[/crayon]$ in post body
|
226 |
// XXX Do this after applying shortcode to avoid matching
|
227 |
$the_content = self::crayon_remove_ignore($the_content);
|
228 |
-
self::$posts[$post_id]['content_crayon'] = $the_content;
|
229 |
return $the_content;
|
230 |
}
|
231 |
|
232 |
// Remove Crayons from the_excerpt
|
233 |
public static function the_excerpt($the_excerpt) {
|
234 |
-
|
235 |
-
$post_id = strval($post->ID);
|
236 |
-
$post->post_content = self::$posts[$post_id]['content'];
|
237 |
-
$post->post_content = preg_replace(self::regex_no_capture(), '', $post->post_content);
|
238 |
$the_excerpt = wpautop(wp_trim_excerpt(''));
|
239 |
-
|
240 |
return $the_excerpt;
|
241 |
}
|
242 |
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
+
Version: 1.3.0
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
36 |
|
37 |
// Associative array, keys are post IDs as strings and values are number of crayons parsed as ints
|
38 |
private static $post_queue = array();
|
39 |
+
// Whether we are displaying an excerpt
|
40 |
+
private static $is_excerpt = FALSE;
|
41 |
// Whether we have added styles and scripts
|
42 |
private static $included = FALSE;
|
43 |
|
67 |
/**
|
68 |
* Adds the actual Crayon instance, should only be called by add_shortcode()
|
69 |
*/
|
70 |
+
private static function shortcode($atts, $content = NULL) {
|
71 |
CrayonSettingsWP::load_settings(); // Run first to ensure global settings loaded
|
72 |
|
73 |
// Lowercase attributes
|
77 |
}
|
78 |
$atts = $lower_atts;
|
79 |
|
|
|
|
|
80 |
// Load attributes from shortcode
|
81 |
$allowed_atts = array('url' => NULL, 'lang' => NULL, 'title' => NULL, 'mark' => NULL);
|
82 |
$filtered_atts = shortcode_atts($allowed_atts, $atts);
|
165 |
}
|
166 |
|
167 |
// Capture attributes
|
168 |
+
preg_match_all('#([^="\'\s]+)[\t ]*=[\t ]*("|\')([^"]+?)\2#', $atts, $att_matches);
|
169 |
$atts_array = array();
|
170 |
|
171 |
if ( count($att_matches[0]) != 0 ) {
|
175 |
}
|
176 |
|
177 |
// Add array of atts and content to post queue with key as post ID
|
178 |
+
self::$post_queue[strval($post->ID)][] = array('id'=>$post->ID, 'atts'=>$atts_array, 'code'=>$contents[$i], 'index'=>$i);
|
179 |
}
|
180 |
}
|
181 |
+
|
182 |
}
|
183 |
|
184 |
if (!is_admin() && $enqueue && !self::$included) {
|
197 |
}
|
198 |
|
199 |
// Add Crayon into the_content
|
200 |
+
public static function the_content($the_content) {
|
201 |
global $post;
|
202 |
// Go through queued posts and find crayons
|
203 |
$post_id = strval($post->ID);
|
204 |
+
|
205 |
+
if (self::$is_excerpt) {
|
206 |
+
// Remove Crayon from content if we are displaying an excerpt
|
207 |
+
return preg_replace(self::regex_no_capture(), '', $the_content);
|
208 |
+
}
|
209 |
+
|
210 |
// Find if this post has Crayons
|
211 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
212 |
// XXX We want the plain post content, no formatting
|
213 |
$the_content_original = $the_content;
|
|
|
214 |
// Loop through Crayons
|
215 |
$post_in_queue = self::$post_queue[$post_id];
|
216 |
foreach ($post_in_queue as $p) {
|
217 |
$atts = $p['atts'];
|
218 |
+
$content = $p['code']; // The formatted crayon we replace post content with
|
|
|
|
|
|
|
219 |
// Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
|
220 |
$content = self::crayon_remove_ignore($content);
|
221 |
// Apply shortcode to the content
|
222 |
$crayon = self::shortcode($atts, $content);
|
223 |
+
$the_content = CrayonUtil::preg_replace_escape_back(self::regex_no_capture(), $crayon, $the_content, 1, $count);
|
224 |
}
|
225 |
}
|
226 |
// Remove '$' from $[crayon]...[/crayon]$ in post body
|
227 |
// XXX Do this after applying shortcode to avoid matching
|
228 |
$the_content = self::crayon_remove_ignore($the_content);
|
|
|
229 |
return $the_content;
|
230 |
}
|
231 |
|
232 |
// Remove Crayons from the_excerpt
|
233 |
public static function the_excerpt($the_excerpt) {
|
234 |
+
self::$is_excerpt = TRUE;
|
|
|
|
|
|
|
235 |
$the_excerpt = wpautop(wp_trim_excerpt(''));
|
236 |
+
self::$is_excerpt = FALSE;
|
237 |
return $the_excerpt;
|
238 |
}
|
239 |
|
css/style.css
CHANGED
@@ -29,6 +29,7 @@ coloring etc.
|
|
29 |
|
30 |
.crayon-syntax .crayon-main,
|
31 |
.crayon-syntax .crayon-toolbar,
|
|
|
32 |
.crayon-syntax .crayon-plain,
|
33 |
.crayon-syntax .crayon-code {
|
34 |
/* Dimensions of code */
|
@@ -81,11 +82,25 @@ coloring etc.
|
|
81 |
}
|
82 |
/* End Line Numbers ================ */
|
83 |
|
84 |
-
/* Toolbar
|
85 |
.crayon-syntax .crayon-toolbar {
|
86 |
position: relative;
|
87 |
overflow: hidden;
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
.crayon-syntax .crayon-toolbar,
|
90 |
.crayon-syntax .crayon-toolbar * {
|
91 |
height: 20px;
|
@@ -125,6 +140,20 @@ coloring etc.
|
|
125 |
background-image: url('images/toolbar/plain_dark.png');
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
/* Nums Button */
|
129 |
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-nums-button:link {
|
130 |
background-image: url('images/toolbar/nums_dark.png');
|
29 |
|
30 |
.crayon-syntax .crayon-main,
|
31 |
.crayon-syntax .crayon-toolbar,
|
32 |
+
.crayon-syntax .crayon-info,
|
33 |
.crayon-syntax .crayon-plain,
|
34 |
.crayon-syntax .crayon-code {
|
35 |
/* Dimensions of code */
|
82 |
}
|
83 |
/* End Line Numbers ================ */
|
84 |
|
85 |
+
/* Toolbar & Info ================== */
|
86 |
.crayon-syntax .crayon-toolbar {
|
87 |
position: relative;
|
88 |
overflow: hidden;
|
89 |
}
|
90 |
+
.crayon-syntax .crayon-info {
|
91 |
+
position: absolute;
|
92 |
+
overflow: hidden;
|
93 |
+
display: none;
|
94 |
+
z-index: 3;
|
95 |
+
min-height: 20px;
|
96 |
+
padding: 0px;
|
97 |
+
line-height: 20px;
|
98 |
+
}
|
99 |
+
.crayon-syntax .crayon-info div {
|
100 |
+
padding: 4px !important;
|
101 |
+
text-align: center;
|
102 |
+
}
|
103 |
+
|
104 |
.crayon-syntax .crayon-toolbar,
|
105 |
.crayon-syntax .crayon-toolbar * {
|
106 |
height: 20px;
|
140 |
background-image: url('images/toolbar/plain_dark.png');
|
141 |
}
|
142 |
|
143 |
+
/* Copy Button */
|
144 |
+
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-copy-button:link {
|
145 |
+
background-image: url('images/toolbar/copy_dark.png');
|
146 |
+
background-position: center;
|
147 |
+
background-repeat: no-repeat;
|
148 |
+
}
|
149 |
+
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-copy-button:hover,
|
150 |
+
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-copy-button.crayon-pressed {
|
151 |
+
background-image: url('images/toolbar/copy_light.png');
|
152 |
+
}
|
153 |
+
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-copy-button:active {
|
154 |
+
background-image: url('images/toolbar/copy_dark.png');
|
155 |
+
}
|
156 |
+
|
157 |
/* Nums Button */
|
158 |
.crayon-syntax .crayon-toolbar a.crayon-button.crayon-nums-button:link {
|
159 |
background-image: url('images/toolbar/nums_dark.png');
|
js/crayon.js
CHANGED
@@ -21,6 +21,7 @@ var UNPRESSED = '';
|
|
21 |
|
22 |
var CRAYON_SYNTAX = 'div.crayon-syntax';
|
23 |
var CRAYON_TOOLBAR = '.crayon-toolbar';
|
|
|
24 |
var CRAYON_PLAIN = '.crayon-plain';
|
25 |
var CRAYON_PLAIN_BUTTON = '.crayon-plain-button';
|
26 |
var CRAYON_MAIN = '.crayon-main';
|
@@ -31,7 +32,6 @@ var CRAYON_NUMS_CONTENT = '.crayon-nums-content';
|
|
31 |
var CRAYON_NUMS_BUTTON = '.crayon-nums-button';
|
32 |
|
33 |
jQuery(document).ready(function() {
|
34 |
-
//crayon_log('crayon loaded');
|
35 |
init();
|
36 |
});
|
37 |
|
@@ -44,6 +44,7 @@ function init() {
|
|
44 |
jQuery(CRAYON_SYNTAX).each(function() {
|
45 |
var uid = jQuery(this).attr('id');
|
46 |
var toolbar = jQuery(this).find(CRAYON_TOOLBAR);
|
|
|
47 |
var plain = jQuery(this).find(CRAYON_PLAIN);
|
48 |
var plain_button = jQuery(this).find(CRAYON_PLAIN_BUTTON);
|
49 |
var main = jQuery(this).find(CRAYON_MAIN);
|
@@ -58,6 +59,7 @@ function init() {
|
|
58 |
crayon[uid].toolbar = toolbar;
|
59 |
crayon[uid].plain = plain;
|
60 |
crayon[uid].plain_button = plain_button;
|
|
|
61 |
crayon[uid].main = main;
|
62 |
crayon[uid].table = table;
|
63 |
crayon[uid].code = code;
|
@@ -67,7 +69,7 @@ function init() {
|
|
67 |
crayon[uid].nums_visible = true;
|
68 |
crayon[uid].plain_visible = false;
|
69 |
|
70 |
-
crayon[uid].toolbar_delay =
|
71 |
crayon[uid].time = 1;
|
72 |
|
73 |
// Set plain
|
@@ -117,14 +119,23 @@ function init() {
|
|
117 |
// Used for toggling
|
118 |
main.css('position', 'relative');
|
119 |
main.css('z-index', 1);
|
120 |
-
|
121 |
-
plain.css('opacity', 0);
|
122 |
// Disable certain features for touchscreen devices
|
123 |
touchscreen = (jQuery(this).filter('[settings~="touchscreen"]').length != 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
// If a toolbar with mouseover was found
|
125 |
if (toolbar.filter('[settings~="mouseover"]').length != 0 && !touchscreen) {
|
126 |
crayon[uid].toolbar_mouseover = true;
|
127 |
-
|
128 |
toolbar.css('margin-top', crayon.toolbar_neg_height);
|
129 |
toolbar.hide();
|
130 |
// Overlay the toolbar if needed, only if doing so will not hide the
|
@@ -135,13 +146,15 @@ function init() {
|
|
135 |
toolbar.css('z-index', 2);
|
136 |
// Hide on single click when overlayed
|
137 |
if (toolbar.filter('[settings~="hide"]').length != 0) {
|
138 |
-
main.click(function() { toolbar_toggle(uid, undefined,
|
139 |
-
plain.click(function() { toolbar_toggle(uid, false,
|
140 |
}
|
141 |
-
}
|
|
|
|
|
142 |
// Enable delay on mouseout
|
143 |
if (toolbar.filter('[settings~="delay"]').length != 0) {
|
144 |
-
crayon[uid].toolbar_delay =
|
145 |
}
|
146 |
// Use .hover() for chrome, but in firefox mouseover/mouseout worked best
|
147 |
jQuery(this).mouseenter(function() { toolbar_toggle(uid, true); })
|
@@ -174,19 +187,114 @@ function init() {
|
|
174 |
if ( jQuery(this).filter('[settings~="disable-anim"]').length != 0 ) {
|
175 |
crayon[uid].time = 0;
|
176 |
}
|
|
|
|
|
|
|
177 |
});
|
178 |
}
|
179 |
|
180 |
function make_uid(uid) {
|
181 |
if (typeof crayon[uid] == 'undefined') {
|
182 |
crayon[uid] = jQuery('#'+uid);
|
183 |
-
//crayon_log('made ' + uid);
|
184 |
return true;
|
185 |
}
|
186 |
return false;
|
187 |
}
|
188 |
|
189 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
if (typeof crayon[uid] == 'undefined') {
|
191 |
return make_uid(uid);
|
192 |
}
|
@@ -264,6 +372,15 @@ function toggle_plain(uid, hover) {
|
|
264 |
hidden.scrollTop(crayon[uid].top);
|
265 |
hidden.scrollLeft(crayon[uid].left + 1);
|
266 |
hidden.scrollLeft(crayon[uid].left);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
});
|
268 |
|
269 |
// Restore scroll positions to hidden
|
@@ -379,7 +496,7 @@ function update_plain_button(uid) {
|
|
379 |
}
|
380 |
}
|
381 |
|
382 |
-
function toolbar_toggle(uid, show,
|
383 |
if (typeof crayon[uid] == 'undefined') {
|
384 |
return make_uid(uid);
|
385 |
} else if (!crayon[uid].toolbar_mouseover) {
|
@@ -387,34 +504,12 @@ function toolbar_toggle(uid, show, instant) {
|
|
387 |
}
|
388 |
var toolbar = crayon[uid].toolbar;
|
389 |
var delay = crayon[uid].toolbar_delay;
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
} else {
|
394 |
-
show = false;
|
395 |
-
}
|
396 |
-
}
|
397 |
-
// Instant means no time delay for showing/hiding
|
398 |
-
if (typeof instant == 'undefined') {
|
399 |
-
instant = false;
|
400 |
-
}
|
401 |
-
toolbar.stop(true);
|
402 |
-
if (show == true) {
|
403 |
-
toolbar.show();
|
404 |
-
toolbar.animate({
|
405 |
-
marginTop: 0
|
406 |
-
}, animt(100, uid));
|
407 |
-
} else if (show == false) {
|
408 |
-
// Delay if fully visible
|
409 |
-
if (instant == false && toolbar.css('margin-top') == '0px' && delay) {
|
410 |
-
toolbar.delay(500);
|
411 |
-
}
|
412 |
-
toolbar.animate({
|
413 |
-
marginTop: crayon.toolbar_neg_height
|
414 |
-
}, animt(100, uid), function() {
|
415 |
-
toolbar.hide();
|
416 |
-
});
|
417 |
}
|
|
|
|
|
418 |
}
|
419 |
|
420 |
function toggle_scroll(uid, show) {
|
21 |
|
22 |
var CRAYON_SYNTAX = 'div.crayon-syntax';
|
23 |
var CRAYON_TOOLBAR = '.crayon-toolbar';
|
24 |
+
var CRAYON_INFO = '.crayon-info';
|
25 |
var CRAYON_PLAIN = '.crayon-plain';
|
26 |
var CRAYON_PLAIN_BUTTON = '.crayon-plain-button';
|
27 |
var CRAYON_MAIN = '.crayon-main';
|
32 |
var CRAYON_NUMS_BUTTON = '.crayon-nums-button';
|
33 |
|
34 |
jQuery(document).ready(function() {
|
|
|
35 |
init();
|
36 |
});
|
37 |
|
44 |
jQuery(CRAYON_SYNTAX).each(function() {
|
45 |
var uid = jQuery(this).attr('id');
|
46 |
var toolbar = jQuery(this).find(CRAYON_TOOLBAR);
|
47 |
+
var info = jQuery(this).find(CRAYON_INFO);
|
48 |
var plain = jQuery(this).find(CRAYON_PLAIN);
|
49 |
var plain_button = jQuery(this).find(CRAYON_PLAIN_BUTTON);
|
50 |
var main = jQuery(this).find(CRAYON_MAIN);
|
59 |
crayon[uid].toolbar = toolbar;
|
60 |
crayon[uid].plain = plain;
|
61 |
crayon[uid].plain_button = plain_button;
|
62 |
+
crayon[uid].info = info;
|
63 |
crayon[uid].main = main;
|
64 |
crayon[uid].table = table;
|
65 |
crayon[uid].code = code;
|
69 |
crayon[uid].nums_visible = true;
|
70 |
crayon[uid].plain_visible = false;
|
71 |
|
72 |
+
crayon[uid].toolbar_delay = 0;
|
73 |
crayon[uid].time = 1;
|
74 |
|
75 |
// Set plain
|
119 |
// Used for toggling
|
120 |
main.css('position', 'relative');
|
121 |
main.css('z-index', 1);
|
122 |
+
|
|
|
123 |
// Disable certain features for touchscreen devices
|
124 |
touchscreen = (jQuery(this).filter('[settings~="touchscreen"]').length != 0);
|
125 |
+
|
126 |
+
// Used to hide info
|
127 |
+
if (!touchscreen) {
|
128 |
+
main.click(function() { crayon_info(uid, '', false); });
|
129 |
+
plain.click(function() { crayon_info(uid, '', false); });
|
130 |
+
info.click(function() { crayon_info(uid, '', false); });
|
131 |
+
}
|
132 |
+
|
133 |
+
plain.css('opacity', 0);
|
134 |
+
crayon.toolbar_neg_height = '-' + toolbar.height() + 'px';
|
135 |
// If a toolbar with mouseover was found
|
136 |
if (toolbar.filter('[settings~="mouseover"]').length != 0 && !touchscreen) {
|
137 |
crayon[uid].toolbar_mouseover = true;
|
138 |
+
|
139 |
toolbar.css('margin-top', crayon.toolbar_neg_height);
|
140 |
toolbar.hide();
|
141 |
// Overlay the toolbar if needed, only if doing so will not hide the
|
146 |
toolbar.css('z-index', 2);
|
147 |
// Hide on single click when overlayed
|
148 |
if (toolbar.filter('[settings~="hide"]').length != 0) {
|
149 |
+
main.click(function() { toolbar_toggle(uid, undefined, undefined, 0); });
|
150 |
+
plain.click(function() { toolbar_toggle(uid, false, undefined, 0); });
|
151 |
}
|
152 |
+
} else {
|
153 |
+
toolbar.css('z-index', 4);
|
154 |
+
}
|
155 |
// Enable delay on mouseout
|
156 |
if (toolbar.filter('[settings~="delay"]').length != 0) {
|
157 |
+
crayon[uid].toolbar_delay = 500;
|
158 |
}
|
159 |
// Use .hover() for chrome, but in firefox mouseover/mouseout worked best
|
160 |
jQuery(this).mouseenter(function() { toolbar_toggle(uid, true); })
|
187 |
if ( jQuery(this).filter('[settings~="disable-anim"]').length != 0 ) {
|
188 |
crayon[uid].time = 0;
|
189 |
}
|
190 |
+
|
191 |
+
// Determine if Mac
|
192 |
+
crayon[uid].mac = (jQuery(this).filter('[crayon-os~="mac"]').length != 0);
|
193 |
});
|
194 |
}
|
195 |
|
196 |
function make_uid(uid) {
|
197 |
if (typeof crayon[uid] == 'undefined') {
|
198 |
crayon[uid] = jQuery('#'+uid);
|
|
|
199 |
return true;
|
200 |
}
|
201 |
return false;
|
202 |
}
|
203 |
|
204 |
+
function copy_plain(uid, hover) {
|
205 |
+
if (typeof crayon[uid] == 'undefined') {
|
206 |
+
return make_uid(uid);
|
207 |
+
}
|
208 |
+
|
209 |
+
var plain = crayon[uid].plain;
|
210 |
+
|
211 |
+
toggle_plain(uid, true, true);
|
212 |
+
toolbar_toggle(uid, true);
|
213 |
+
|
214 |
+
key = crayon[uid].mac ? '\u2318' : 'CTRL';
|
215 |
+
text = 'Press ' + key + '+C to Copy, ' + key + '+P to Paste :)';
|
216 |
+
crayon_info(uid, text);
|
217 |
+
}
|
218 |
+
|
219 |
+
function crayon_info(uid, text, show) {
|
220 |
+
if (typeof crayon[uid] == 'undefined') {
|
221 |
+
return make_uid(uid);
|
222 |
+
}
|
223 |
+
|
224 |
+
var info = crayon[uid].info;
|
225 |
+
|
226 |
+
if (typeof text == 'undefined') {
|
227 |
+
text = '';
|
228 |
+
}
|
229 |
+
if (typeof show == 'undefined') {
|
230 |
+
show = true;
|
231 |
+
}
|
232 |
+
|
233 |
+
if (crayon_is_slide_hidden(info) && show) {
|
234 |
+
info.html('<div>' + text + '</div>');
|
235 |
+
info.css('margin-top', -info.height());
|
236 |
+
info.show();
|
237 |
+
crayon_slide(uid, info, true);
|
238 |
+
setTimeout(function() {
|
239 |
+
crayon_slide(uid, info, false);
|
240 |
+
}, 5000);
|
241 |
+
}
|
242 |
+
|
243 |
+
if (!show) {
|
244 |
+
crayon_slide(uid, info, false);
|
245 |
+
}
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
function crayon_is_slide_hidden(object) {
|
250 |
+
var object_neg_height = '-' + object.height() + 'px';
|
251 |
+
if (object.css('margin-top') == object_neg_height || object.css('display') == 'none') {
|
252 |
+
return true;
|
253 |
+
} else {
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
function crayon_slide(uid, object, show, anim_time, hide_delay) {
|
259 |
+
var object_neg_height = '-' + object.height() + 'px';
|
260 |
+
|
261 |
+
if (typeof show == 'undefined') {
|
262 |
+
if (crayon_is_slide_hidden(object)) {
|
263 |
+
show = true;
|
264 |
+
} else {
|
265 |
+
show = false;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
// Instant means no time delay for showing/hiding
|
269 |
+
if (typeof anim_time == 'undefined') {
|
270 |
+
anim_time = 100;
|
271 |
+
}
|
272 |
+
if (anim_time == false) {
|
273 |
+
anim_time = false;
|
274 |
+
}
|
275 |
+
if (typeof hide_delay== 'undefined') {
|
276 |
+
hide_delay = 0;
|
277 |
+
}
|
278 |
+
object.stop(true);
|
279 |
+
if (show == true) {
|
280 |
+
object.show();
|
281 |
+
object.animate({
|
282 |
+
marginTop: 0
|
283 |
+
}, animt(anim_time, uid));
|
284 |
+
} else if (show == false) {
|
285 |
+
// Delay if fully visible
|
286 |
+
if (/*instant == false && */object.css('margin-top') == '0px' && hide_delay) {
|
287 |
+
object.delay(hide_delay);
|
288 |
+
}
|
289 |
+
object.animate({
|
290 |
+
marginTop: object_neg_height
|
291 |
+
}, animt(anim_time, uid), function() {
|
292 |
+
object.hide();
|
293 |
+
});
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
function toggle_plain(uid, hover, select) {
|
298 |
if (typeof crayon[uid] == 'undefined') {
|
299 |
return make_uid(uid);
|
300 |
}
|
372 |
hidden.scrollTop(crayon[uid].top);
|
373 |
hidden.scrollLeft(crayon[uid].left + 1);
|
374 |
hidden.scrollLeft(crayon[uid].left);
|
375 |
+
|
376 |
+
// Give focus to plain code
|
377 |
+
if (hidden == plain) {
|
378 |
+
if (select) {
|
379 |
+
plain.select();
|
380 |
+
} else {
|
381 |
+
plain.focus();
|
382 |
+
}
|
383 |
+
}
|
384 |
});
|
385 |
|
386 |
// Restore scroll positions to hidden
|
496 |
}
|
497 |
}
|
498 |
|
499 |
+
function toolbar_toggle(uid, show, anim_time, hide_delay) {
|
500 |
if (typeof crayon[uid] == 'undefined') {
|
501 |
return make_uid(uid);
|
502 |
} else if (!crayon[uid].toolbar_mouseover) {
|
504 |
}
|
505 |
var toolbar = crayon[uid].toolbar;
|
506 |
var delay = crayon[uid].toolbar_delay;
|
507 |
+
|
508 |
+
if (typeof hide_delay == 'undefined') {
|
509 |
+
hide_delay = crayon[uid].toolbar_delay;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
}
|
511 |
+
|
512 |
+
crayon_slide(uid, toolbar, show, anim_time, hide_delay);
|
513 |
}
|
514 |
|
515 |
function toggle_scroll(uid, show) {
|
js/crayon_admin.js
CHANGED
@@ -80,6 +80,17 @@ function admin_init() {
|
|
80 |
toggle_toolbar();
|
81 |
toolbar.change(function() { toggle_toolbar(); });
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
// Log
|
84 |
var show_log = 'Show Log';
|
85 |
var hide_log = 'Hide Log';
|
80 |
toggle_toolbar();
|
81 |
toolbar.change(function() { toggle_toolbar(); });
|
82 |
|
83 |
+
// Copy
|
84 |
+
plain = jQuery('#plain');
|
85 |
+
copy = jQuery('#crayon-copy-check');
|
86 |
+
plain.change(function() {
|
87 |
+
if (plain.is(':checked')) {
|
88 |
+
copy.show();
|
89 |
+
} else {
|
90 |
+
copy.hide();
|
91 |
+
}
|
92 |
+
});
|
93 |
+
|
94 |
// Log
|
95 |
var show_log = 'Show Log';
|
96 |
var hide_log = 'Hide Log';
|
langs/default/statement.txt
CHANGED
@@ -16,6 +16,7 @@ catch
|
|
16 |
endif
|
17 |
throw
|
18 |
while
|
|
|
19 |
case
|
20 |
else
|
21 |
goto
|
16 |
endif
|
17 |
throw
|
18 |
while
|
19 |
+
then
|
20 |
case
|
21 |
else
|
22 |
goto
|
langs/sh/reserved.txt
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
uncompress
|
2 |
+
localedef
|
3 |
+
basename
|
4 |
+
compress
|
5 |
+
unexpand
|
6 |
+
uudecode
|
7 |
+
uuencode
|
8 |
+
command
|
9 |
+
crontab
|
10 |
+
dirname
|
11 |
+
getconf
|
12 |
+
getopts
|
13 |
+
logname
|
14 |
+
pathchk
|
15 |
+
qselect
|
16 |
+
strings
|
17 |
+
unalias
|
18 |
+
csplit
|
19 |
+
expand
|
20 |
+
fort77
|
21 |
+
gencat
|
22 |
+
locale
|
23 |
+
logger
|
24 |
+
mkfifo
|
25 |
+
newgrp
|
26 |
+
printf
|
27 |
+
qalter
|
28 |
+
qrerun
|
29 |
+
renice
|
30 |
+
ulimit
|
31 |
+
unlink
|
32 |
+
uustat
|
33 |
+
alias
|
34 |
+
batch
|
35 |
+
cflow
|
36 |
+
chgrp
|
37 |
+
chmod
|
38 |
+
chown
|
39 |
+
cksum
|
40 |
+
clear
|
41 |
+
ctags
|
42 |
+
cxref
|
43 |
+
delta
|
44 |
+
fuser
|
45 |
+
iconv
|
46 |
+
ipcrm
|
47 |
+
mailx
|
48 |
+
mkdir
|
49 |
+
nohup
|
50 |
+
paste
|
51 |
+
patch
|
52 |
+
qhold
|
53 |
+
qmove
|
54 |
+
qstat
|
55 |
+
rmdel
|
56 |
+
rmdir
|
57 |
+
sleep
|
58 |
+
split
|
59 |
+
strip
|
60 |
+
touch
|
61 |
+
tsort
|
62 |
+
umask
|
63 |
+
uname
|
64 |
+
unget
|
65 |
+
write
|
66 |
+
xargs
|
67 |
+
comm
|
68 |
+
date
|
69 |
+
diff
|
70 |
+
echo
|
71 |
+
expr
|
72 |
+
file
|
73 |
+
find
|
74 |
+
fold
|
75 |
+
grep
|
76 |
+
hash
|
77 |
+
head
|
78 |
+
ipcs
|
79 |
+
jobs
|
80 |
+
join
|
81 |
+
kill
|
82 |
+
link
|
83 |
+
make
|
84 |
+
mesg
|
85 |
+
more
|
86 |
+
nice
|
87 |
+
qdel
|
88 |
+
qmsg
|
89 |
+
qrls
|
90 |
+
qsig
|
91 |
+
qsub
|
92 |
+
read
|
93 |
+
sact
|
94 |
+
sccs
|
95 |
+
sort
|
96 |
+
stty
|
97 |
+
tabs
|
98 |
+
tail
|
99 |
+
talk
|
100 |
+
test
|
101 |
+
time
|
102 |
+
tput
|
103 |
+
type
|
104 |
+
uniq
|
105 |
+
uucp
|
106 |
+
wait
|
107 |
+
what
|
108 |
+
yacc
|
109 |
+
zcat
|
110 |
+
asa
|
111 |
+
awk
|
112 |
+
c99
|
113 |
+
cal
|
114 |
+
cat
|
115 |
+
cmp
|
116 |
+
cut
|
117 |
+
env
|
118 |
+
get
|
119 |
+
lex
|
120 |
+
man
|
121 |
+
pax
|
122 |
+
prs
|
123 |
+
pwd
|
124 |
+
sed
|
125 |
+
tee
|
126 |
+
tty
|
127 |
+
uux
|
128 |
+
val
|
129 |
+
who
|
130 |
+
ar
|
131 |
+
at
|
132 |
+
bc
|
133 |
+
bg
|
134 |
+
cd
|
135 |
+
cp
|
136 |
+
dd
|
137 |
+
df
|
138 |
+
du
|
139 |
+
ed
|
140 |
+
ex
|
141 |
+
fc
|
142 |
+
fg
|
143 |
+
id
|
144 |
+
ln
|
145 |
+
lp
|
146 |
+
ls
|
147 |
+
m4
|
148 |
+
mv
|
149 |
+
nl
|
150 |
+
nm
|
151 |
+
od
|
152 |
+
pr
|
153 |
+
ps
|
154 |
+
rm
|
155 |
+
sh
|
156 |
+
tr
|
157 |
+
vi
|
158 |
+
wc
|
langs/sh/sh.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### SHELL LANGUAGE ###
|
2 |
+
|
3 |
+
# ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
|
4 |
+
|
5 |
+
NAME Shell Script
|
6 |
+
VERSION 1.0
|
7 |
+
|
8 |
+
COMMENT (?default)|(#.*?$)
|
9 |
+
STRING (?default)
|
10 |
+
|
11 |
+
STATEMENT (?default)|\b(?alt:statement.txt)\b
|
12 |
+
RESERVED (?default)|\b(?alt:reserved.txt)\b
|
13 |
+
TYPE (?default)
|
14 |
+
|
15 |
+
ENTITY (?default)|(\.[a-z_]\w*\b)
|
16 |
+
VARIABLE (?default)|(\$[a-z_]\w*\b)
|
17 |
+
IDENTIFIER (?default)
|
18 |
+
CONSTANT (?default)
|
19 |
+
OPERATOR (?default)
|
20 |
+
SYMBOL (?default)
|
langs/sh/statement.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
until
|
2 |
+
esac
|
3 |
+
done
|
4 |
+
elif
|
5 |
+
fi
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://ak.net84.net/
|
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
|
10 |
|
@@ -44,28 +44,33 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
44 |
|
45 |
== Changelog ==
|
46 |
|
47 |
-
= 1.
|
48 |
-
*
|
49 |
-
|
50 |
-
|
51 |
-
* Fixed a bug
|
52 |
-
|
53 |
-
|
54 |
-
*
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
= 1.
|
57 |
-
*
|
58 |
-
|
59 |
|
60 |
-
= 1.
|
61 |
-
*
|
62 |
-
|
63 |
-
* Attribute names can be given in any case in shortcodes
|
64 |
-
* Fixes settings bug regarding copy constructor for locked settings
|
65 |
-
* Minor bug fixes and cleanups
|
66 |
|
67 |
-
= 1.
|
68 |
-
*
|
|
|
|
|
|
|
69 |
|
70 |
= 1.2.0 =
|
71 |
* Recommended upgrade for everyone.
|
@@ -75,19 +80,28 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
75 |
* Removed redundant dependency on filesystem path slashes
|
76 |
* PHP now fades surrounding HTML
|
77 |
|
78 |
-
= 1.
|
79 |
-
*
|
80 |
-
** [crayon start-line="1234"]fun code[/crayon]
|
81 |
-
* Thanks for the suggestion from travishill:
|
82 |
-
** http://wordpress.org/support/topic/plugin-crayon-syntax-highlighter-add-the-ability-to-specify-starting-line-number?replies=2#post-2389518
|
83 |
|
84 |
-
= 1.
|
85 |
-
*
|
86 |
-
|
|
|
|
|
|
|
87 |
|
88 |
-
= 1.
|
89 |
-
*
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
== Upgrade Notice ==
|
93 |
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 1.3.0
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
|
10 |
|
44 |
|
45 |
== Changelog ==
|
46 |
|
47 |
+
= 1.3.0 =
|
48 |
+
* Recommended upgrade for everyone.
|
49 |
+
* Major bug fix thanks to twitter.com/42dotno and twitter.com/eriras
|
50 |
+
* Fixed a bug causing attributes using single quotes to be undetected
|
51 |
+
* Fixed a bug causing code with dollar signs followed by numbers to be detected as backreferences and replace itself!
|
52 |
+
* Fixed a bug causing formatting to be totally disregarded.
|
53 |
+
* Fixed the <!--more--> tag in post_content and the_excerpt by placing crayon detection after all other formatting has taken place
|
54 |
+
* Added copy and paste, didn't use flash, selects text and asks user to copy (more elegant until they sort out clipboard access)
|
55 |
+
* Added shell script to languages - use with lang='sh'
|
56 |
+
* Removed certain usage of heredocs and replaced with string concatenation
|
57 |
+
* Added 'then' to default statements
|
58 |
+
* Cleaned up processing of post_queue used for Crayon detection and the_excerpt
|
59 |
+
* Added focus to plain text to allow easier copy-paste
|
60 |
|
61 |
+
= 1.2.3 =
|
62 |
+
* Prevented Crayons from appearing as plain text in excerpts
|
63 |
+
http://wordpress.org/support/topic/plugin-crayon-syntax-highlighter-this-plugin-breaks-the-tag
|
64 |
|
65 |
+
= 1.2.2 =
|
66 |
+
* Fixed the regex for detecting python docstrings. It's a killer, but it works!
|
67 |
+
(?:(?<!\\)""".*?(?<!\\)""")|(?:(?<!\\)'''.*?(?<!\\)''')|((?<!\\)".*?(?<!\\)")|((?<!\\)'.*?(?<!\\)')
|
|
|
|
|
|
|
68 |
|
69 |
+
= 1.2.1 =
|
70 |
+
* Added the feature to specify the starting line number both globally in settings and also using the attribute:
|
71 |
+
** [crayon start-line="1234"]fun code[/crayon]
|
72 |
+
* Thanks for the suggestion from travishill:
|
73 |
+
** http://wordpress.org/support/topic/plugin-crayon-syntax-highlighter-add-the-ability-to-specify-starting-line-number?replies=2#post-2389518
|
74 |
|
75 |
= 1.2.0 =
|
76 |
* Recommended upgrade for everyone.
|
80 |
* Removed redundant dependency on filesystem path slashes
|
81 |
* PHP now fades surrounding HTML
|
82 |
|
83 |
+
= 1.1.1 =
|
84 |
+
* Plugin version information is updated automatically
|
|
|
|
|
|
|
85 |
|
86 |
+
= 1.1.0 =
|
87 |
+
* Recommended upgrade for everyone running 1.0.3.
|
88 |
+
* Fixes a bug that causes code become unhighlighted
|
89 |
+
* Attribute names can be given in any case in shortcodes
|
90 |
+
* Fixes settings bug regarding copy constructor for locked settings
|
91 |
+
* Minor bug fixes and cleanups
|
92 |
|
93 |
+
= 1.0.3 =
|
94 |
+
* Added highlight="false" attribute to temporarily disable highlighting.
|
95 |
+
* Fixed default color of font for twilight font.
|
96 |
+
|
97 |
+
= 1.0.2 =
|
98 |
+
* Minor bug fixes.
|
99 |
+
|
100 |
+
= 1.0.1 =
|
101 |
+
* Fixed a bug that caused Themes not to load for some Crayons due to Wordpress content formatting.
|
102 |
+
|
103 |
+
= 1.0.0 =
|
104 |
+
* Initial Release. Huzzah!
|
105 |
|
106 |
== Upgrade Notice ==
|
107 |
|
themes/classic/classic.css
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/*
|
2 |
Theme Name: Classic
|
3 |
Description: Clean, crisp and colorful.
|
4 |
-
Version: 1.
|
5 |
Author: Aram Kocharyan
|
6 |
Author URI: http://ak.net84.net/
|
7 |
*/
|
@@ -29,6 +29,8 @@ Author URI: http://ak.net84.net/
|
|
29 |
.crayon-theme-classic::selection,
|
30 |
.crayon-theme-classic .crayon-toolbar::selection,
|
31 |
.crayon-theme-classic .crayon-toolbar *::selection,
|
|
|
|
|
32 |
.crayon-theme-classic .crayon-nums::selection,
|
33 |
.crayon-theme-classic .crayon-nums *::selection {
|
34 |
background: transparent !important;
|
@@ -71,6 +73,13 @@ Author URI: http://ak.net84.net/
|
|
71 |
border-bottom-style: solid !important;
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
/* Toolbar */
|
75 |
.crayon-theme-classic .crayon-toolbar {
|
76 |
background: #DDD !important;
|
1 |
/*
|
2 |
Theme Name: Classic
|
3 |
Description: Clean, crisp and colorful.
|
4 |
+
Version: 1.3
|
5 |
Author: Aram Kocharyan
|
6 |
Author URI: http://ak.net84.net/
|
7 |
*/
|
29 |
.crayon-theme-classic::selection,
|
30 |
.crayon-theme-classic .crayon-toolbar::selection,
|
31 |
.crayon-theme-classic .crayon-toolbar *::selection,
|
32 |
+
.crayon-theme-classic .crayon-info::selection,
|
33 |
+
.crayon-theme-classic .crayon-info *::selection,
|
34 |
.crayon-theme-classic .crayon-nums::selection,
|
35 |
.crayon-theme-classic .crayon-nums *::selection {
|
36 |
background: transparent !important;
|
73 |
border-bottom-style: solid !important;
|
74 |
}
|
75 |
|
76 |
+
/* Info */
|
77 |
+
.crayon-theme-classic .crayon-info {
|
78 |
+
background: #faf9d7 !important;
|
79 |
+
border-bottom: 1px #b1af5e solid !important;
|
80 |
+
color: #7e7d34;
|
81 |
+
}
|
82 |
+
|
83 |
/* Toolbar */
|
84 |
.crayon-theme-classic .crayon-toolbar {
|
85 |
background: #DDD !important;
|
themes/twilight/twilight.css
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/*
|
2 |
Theme Name: Twilight
|
3 |
Description: Dark and elegant.
|
4 |
-
Version: 1.
|
5 |
Author: Aram Kocharyan
|
6 |
Author URI: http://ak.net84.net/
|
7 |
*/
|
@@ -34,6 +34,8 @@ Author URI: http://ak.net84.net/
|
|
34 |
.crayon-theme-twilight::selection,
|
35 |
.crayon-theme-twilight .crayon-toolbar::selection,
|
36 |
.crayon-theme-twilight .crayon-toolbar *::selection,
|
|
|
|
|
37 |
.crayon-theme-twilight .crayon-nums::selection,
|
38 |
.crayon-theme-twilight .crayon-nums *::selection {
|
39 |
background: transparent !important;
|
@@ -76,6 +78,13 @@ Author URI: http://ak.net84.net/
|
|
76 |
border-bottom-style: solid !important;
|
77 |
}
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
/* Toolbar */
|
80 |
.crayon-theme-twilight .crayon-toolbar {
|
81 |
background: #b2b2b2 !important;
|
1 |
/*
|
2 |
Theme Name: Twilight
|
3 |
Description: Dark and elegant.
|
4 |
+
Version: 1.3
|
5 |
Author: Aram Kocharyan
|
6 |
Author URI: http://ak.net84.net/
|
7 |
*/
|
34 |
.crayon-theme-twilight::selection,
|
35 |
.crayon-theme-twilight .crayon-toolbar::selection,
|
36 |
.crayon-theme-twilight .crayon-toolbar *::selection,
|
37 |
+
.crayon-theme-twilight .crayon-info::selection,
|
38 |
+
.crayon-theme-twilight .crayon-info *::selection,
|
39 |
.crayon-theme-twilight .crayon-nums::selection,
|
40 |
.crayon-theme-twilight .crayon-nums *::selection {
|
41 |
background: transparent !important;
|
78 |
border-bottom-style: solid !important;
|
79 |
}
|
80 |
|
81 |
+
/* Info */
|
82 |
+
.crayon-theme-twilight .crayon-info {
|
83 |
+
background: #faf9d7 !important;
|
84 |
+
border-bottom: 1px #b1af5e solid !important;
|
85 |
+
color: #7e7d34;
|
86 |
+
}
|
87 |
+
|
88 |
/* Toolbar */
|
89 |
.crayon-theme-twilight .crayon-toolbar {
|
90 |
background: #b2b2b2 !important;
|
util/crayon_util.class.php
CHANGED
@@ -359,6 +359,30 @@ class CrayonUtil {
|
|
359 |
|
360 |
}
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
// Decodes WP html entities
|
363 |
public static function html_entity_decode_wp($str) {
|
364 |
if (!is_string($str) || empty($str)) {
|
359 |
|
360 |
}
|
361 |
|
362 |
+
// Escapes $ and \ from the replacement to avoid becoming a backreference
|
363 |
+
public static function preg_replace_escape_back($pattern, $replacement, $subject, $limit=-1, &$count=0) {
|
364 |
+
return preg_replace($pattern, self::preg_escape_back($replacement), $subject, $limit, $count);
|
365 |
+
}
|
366 |
+
|
367 |
+
// Escape backreferences from string for use with regex
|
368 |
+
public static function preg_escape_back($string) {
|
369 |
+
// Replace $ with \$ and \ with \\
|
370 |
+
$string = preg_replace('#(?<!\\\\)(\\$|\\\\)#', '\\\\$1', $string);
|
371 |
+
return $string;
|
372 |
+
}
|
373 |
+
|
374 |
+
// Detect if on a Mac or PC
|
375 |
+
public static function is_mac($default = FALSE) {
|
376 |
+
$user = $_SERVER['HTTP_USER_AGENT'];
|
377 |
+
if (stripos($user, 'macintosh')) {
|
378 |
+
return TRUE;
|
379 |
+
} else if (stripos($user, 'windows') || stripos($user, 'linux')) {
|
380 |
+
return FALSE;
|
381 |
+
} else {
|
382 |
+
return $default===TRUE;
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
// Decodes WP html entities
|
387 |
public static function html_entity_decode_wp($str) {
|
388 |
if (!is_string($str) || empty($str)) {
|
util/preview.php
CHANGED
@@ -29,7 +29,7 @@ $path = crayon_pf( dirname(__FILE__) . '/sample/' . $lang . '.txt' );
|
|
29 |
if ($lang && @file_exists($path)) {
|
30 |
$crayon->url($path);
|
31 |
} else {
|
32 |
-
$code =
|
33 |
// A sample class
|
34 |
class Human {
|
35 |
private int age = 0;
|
@@ -38,7 +38,7 @@ class Human {
|
|
38 |
print('Happy Birthday!');
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
$crayon->code($code);
|
43 |
}
|
44 |
$crayon->title('Sample Code');
|
29 |
if ($lang && @file_exists($path)) {
|
30 |
$crayon->url($path);
|
31 |
} else {
|
32 |
+
$code = "
|
33 |
// A sample class
|
34 |
class Human {
|
35 |
private int age = 0;
|
38 |
print('Happy Birthday!');
|
39 |
}
|
40 |
}
|
41 |
+
";
|
42 |
$crayon->code($code);
|
43 |
}
|
44 |
$crayon->title('Sample Code');
|