Crayon Syntax Highlighter - Version 2.7.0

Version Description

  • ADDED:
    • Onderka15 theme.
    • Obsidian Light theme.
  • FIXED:
    • Prevented using is_admin() as a security query (thanks to g0blin Research).
    • Removed the ability to load files from the filesystem due to security vulnerabilities (thanks to Kevin Subileau). Ensure all URLs are publicly accessible.
    • Fixed a bug causing tags to be removed in some cases.
Download this release

Release Info

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

Code changes from version 2.6.10 to 2.7.0

.gitmodules CHANGED
@@ -6,4 +6,4 @@ url=git://github.com/aramk/colorpicker.git
6
  url = https://github.com/antiphasis/crayon-lang-ada.git
7
  [submodule "langs/vbnet"]
8
  path = langs/vbnet
9
- url = https://github.com/OomJan/crayon-lang-vbnet.git
6
  url = https://github.com/antiphasis/crayon-lang-ada.git
7
  [submodule "langs/vbnet"]
8
  path = langs/vbnet
9
+ url=https://github.com/NuGardt/crayon-lang-vbnet.git
crayon_formatter.class.php CHANGED
@@ -1,630 +1,633 @@
1
  <?php
2
- require_once ('global.php');
3
- require_once (CRAYON_HIGHLIGHTER_PHP);
4
- require_once (CRAYON_SETTINGS_PHP);
5
- require_once (CRAYON_PARSER_PHP);
6
- require_once (CRAYON_THEMES_PHP);
7
 
8
  /* Manages formatting the html with html and css. */
 
9
  class CrayonFormatter {
10
- // Properties and Constants ===============================================
11
- /* Used to temporarily store the array of CrayonElements passed to format_code(), so that
12
- format_matches() can access them and identify which elements were captured and format
13
- accordingly. This must be static for preg_replace_callback() to access it.*/
14
- private static $elements = array();
15
-
16
- // Delimiters
17
- // Current crayon undergoing delimiter replace
18
- private static $curr;
19
- private static $delimiters;
20
- private static $delim_regex;
21
- private static $delim_pieces;
22
-
23
- // Methods ================================================================
24
- private function __construct() {}
25
-
26
- /* Formats the code using the parsed language elements. */
27
- public static function format_code($code, $language, $hl = NULL) {
28
- // Ensure the language is defined
29
- if ($language != NULL && $hl->is_highlighted()) {
30
- $code = self::clean_code($code, FALSE, FALSE, FALSE, TRUE);
31
- /* Perform the replace on the code using the regex, pass the captured matches for
32
- formatting before they are replaced */
33
- try {
34
- CrayonParser::parse($language->id());
35
- // Match language regex
36
- $elements = $language->elements();
37
- $regex = $language->regex();
38
- if (!empty($regex) && !empty($elements)) {
39
- // Get array of CrayonElements
40
- self::$elements = array_values($elements);
41
- $code = preg_replace_callback($regex, 'CrayonFormatter::format_match', $code);
42
- }
43
- } catch (Exception $e) {
44
- $error = 'An error occured when formatting: ' . $e->message();
45
- $hl ? $hl->log($error) : CrayonLog::syslog($error);
46
- }
47
- return $code;
48
- } else {
49
- return self::clean_code($code, TRUE, TRUE, TRUE, TRUE);
50
- }
51
- }
52
-
53
- /* Performs a replace to format each match based on the captured element. */
54
- private static function format_match($matches) {
55
- /* First index in $matches is full match, subsequent indices are groups.
56
- * Minimum number of elements in array is 2, so minimum captured group is 0. */
57
- $captured_group_number = count($matches) - 2;
58
- $code = $matches[0];
59
- if (array_key_exists($captured_group_number, self::$elements)) {
60
- $captured_element = self::$elements[$captured_group_number];
61
- // Avoid capturing and formatting internal Crayon elements
62
- if ($captured_element->name() == CrayonParser::CRAYON_ELEMENT) {
63
- return $code; // Return as is
64
- } else {
65
- // Separate lines and add css class, keep extended class last to allow overriding
66
- $fallback_css = CrayonLangs::known_elements($captured_element->fallback());
67
- $element_css = $captured_element->css();
68
- $css = !empty($fallback_css) ? $fallback_css . ' ' . $element_css : $element_css ;
69
- return self::split_lines($code, $css);
70
- }
71
- } else {
72
- // All else fails, return the match
73
- return $matches[0];
74
- }
75
- }
76
-
77
- /* Prints the formatted code, option to override the line numbers with a custom string */
78
- public static function print_code($hl, $code, $line_numbers = TRUE, $print = TRUE) {
79
- global $CRAYON_VERSION;
80
-
81
- // We can print either block or inline, inline is treated differently, factor out common stuff here
82
- $output = '';
83
- // Used for style tag
84
- $main_style = $code_style = $toolbar_style = $info_style = $font_style = $line_style = $pre_style = '';
85
- // Unique ID for this instance of Crayon
86
- $uid = 'crayon-' . $hl->id();
87
- // Print theme id
88
- // We make the assumption that the id is correct (checked in crayon_wp)
89
- $theme_id = $hl->setting_val(CrayonSettings::THEME);
90
- $theme_id_dashed = CrayonUtil::space_to_hyphen($theme_id);
91
- if (!$hl->setting_val(CrayonSettings::ENQUEUE_THEMES)) {
92
- $output .= CrayonResources::themes()->get_css($theme_id);
93
- }
94
-
95
- // Print font id
96
- // We make the assumption that the id is correct (checked in crayon_wp)
97
- $font_id = $hl->setting_val(CrayonSettings::FONT);
98
- $font_id_dashed = CrayonUtil::space_to_hyphen($font_id);
99
- if (!$hl->setting_val(CrayonSettings::ENQUEUE_FONTS)) {
100
- $output .= CrayonResources::fonts()->get_css($font_id);
101
- }
102
-
103
- // Inline margin
104
- if ($hl->is_inline()) {
105
- $inline_margin = $hl->setting_val(CrayonSettings::INLINE_MARGIN) . 'px !important;';
106
- }
107
-
108
- // Determine font size
109
- // TODO improve logic
110
- if ($hl->setting_val(CrayonSettings::FONT_SIZE_ENABLE)) {
 
111
  $_font_size = $hl->setting_val(CrayonSettings::FONT_SIZE);
112
- $font_size = $_font_size . 'px !important;';
113
  $_line_height = $hl->setting_val(CrayonSettings::LINE_HEIGHT);
114
  // Don't allow line height to be less than font size
115
  $line_height = ($_line_height > $_font_size ? $_line_height : $_font_size) . 'px !important;';
116
- $toolbar_height = $font_size * 1.5 . 'px !important;';
117
- $info_height = $font_size * 1.4 . 'px !important;';
118
 
119
- $font_style .= "font-size: $font_size line-height: $line_height";
120
  $toolbar_style .= "font-size: $font_size";
121
- $line_style .= "height: $line_height";
122
-
123
- if ($hl->is_inline()) {
124
- $font_style .= "font-size: $font_size";
125
- } else {
126
- $toolbar_style .= "height: $toolbar_height line-height: $toolbar_height";
127
- $info_style .= "min-height: $info_height line-height: $info_height";
128
- }
129
- } else if (!$hl->is_inline()) {
130
- if (($font_size = CrayonGlobalSettings::get(CrayonSettings::FONT_SIZE)) !== FALSE) {
131
- $font_size = $font_size->def() . 'px !important;';
132
  $line_height = ($font_size * 1.4) . 'px !important;';
133
- }
134
- }
135
 
136
  $tab = $hl->setting_val(CrayonSettings::TAB_SIZE);
137
  $pre_style = "-moz-tab-size:$tab; -o-tab-size:$tab; -webkit-tab-size:$tab; tab-size:$tab;";
138
 
139
- // This will return from function with inline print
140
- if ($hl->is_inline()) {
141
- $wrap = !$hl->setting_val(CrayonSettings::INLINE_WRAP) ? 'crayon-syntax-inline-nowrap' : '';
142
- $output .= '
143
- <span id="'.$uid.'" class="crayon-syntax crayon-syntax-inline '.$wrap.' crayon-theme-'.$theme_id_dashed.' crayon-theme-'.$theme_id_dashed.'-inline crayon-font-'.$font_id_dashed.'" style="'.$font_style.'">' .
144
- '<span class="crayon-pre crayon-code" style="'.$font_style.' '.$pre_style.'">' . $code . '</span>' .
145
- '</span>';
146
- return $output;
147
- }
148
-
149
- // Below code only for block (default) printing
150
-
151
- // Generate the code lines and separate each line as a div
152
- $print_code = '';
153
- $print_nums = '';
154
- $hl->line_count(preg_match_all("#(?:^|(?<=\r\n|\n))[^\r\n]*#", $code, $code_lines));
155
-
156
- // The line number to start from
157
- $start_line = $hl->setting_val(CrayonSettings::START_LINE);
158
- $marking = $hl->setting_val(CrayonSettings::MARKING);
159
- $striped = $hl->setting_val(CrayonSettings::STRIPED);
160
- $range = $hl->setting_val(CrayonSettings::RANGES) ? $hl->range() : FALSE;
161
- for ($i = 1; $i <= $hl->line_count(); $i++) {
162
- // Check if the current line is in the range of code to display
163
- if ($range){
164
- if ($i < $range[0]) {
165
- continue;
166
- } else if ($i > $range[1]) {
167
- break;
168
- }
169
- }
170
- $code_line = $code_lines[0][$i - 1];
171
-
172
- // If line is blank, add a space so the div has the correct height
173
- if ($code_line == '') {
174
- $code_line = '&nbsp;';
175
- }
176
-
177
- // Check if the current line has been selected
178
- $marked_lines = $hl->marked();
179
- // Check if lines need to be marked as important
180
- if ($marking && in_array($i, $marked_lines)) {
181
- $marked_num = ' crayon-marked-num';
182
- $marked_line = ' crayon-marked-line';
183
- // If multiple lines are marked, only show borders for top and bottom lines
184
- if (!in_array($i - 1, $marked_lines)) {
185
- $marked_num .= ' crayon-top';
186
- $marked_line .= ' crayon-top';
187
- }
188
- // Single lines are both the top and bottom of the multiple marked lines
189
- if (!in_array($i + 1, $marked_lines)) {
190
- $marked_num .= ' crayon-bottom';
191
- $marked_line .= ' crayon-bottom';
192
- }
193
- } else {
194
- $marked_num = $marked_line = '';
195
- }
196
- // Stripe odd lines
197
- if ($striped && $i % 2 == 0) {
198
- $striped_num = ' crayon-striped-num';
199
- $striped_line = ' crayon-striped-line';
200
- } else {
201
- $striped_num = $striped_line = '';
202
- }
203
- // Generate the lines
204
- $line_num = $start_line + $i - 1;
205
- $line_id = $uid.'-' . $line_num;
206
- $print_code .= '<div class="crayon-line' . $marked_line . $striped_line . '" id="'.$line_id.'">' . $code_line . '</div>';
207
- if (!is_string($line_numbers)) {
208
- $print_nums .= '<div class="crayon-num' . $marked_num . $striped_num . '" data-line="'.$line_id.'">' . $line_num . '</div>';
209
- }
210
- }
211
- // If $line_numbers is a string, display it
212
- if (is_string($line_numbers) && !empty($line_numbers)) {
213
- $print_nums .= '<div class="crayon-num">' . $line_numbers . '</div>';
214
- } else if ( empty($line_numbers) ) {
215
- $print_nums = FALSE;
216
- }
217
- // Determine whether to print title, encode characters
218
- $title = $hl->title();
219
- // Decode if needed
220
- if ($hl->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
221
- $title = CrayonUtil::html_entity_decode($title);
222
- }
223
- $print_title = '<span class="crayon-title">' . $title . '</span>';
224
- // Determine whether to print language
225
- $print_lang = '';
226
- // XXX Use for printing the regex
227
- if ($hl->language()) {
228
- $lang = $hl->language()->name();
229
- switch ($hl->setting_index(CrayonSettings::SHOW_LANG)) {
230
- case 0 :
231
- if ($hl->language()->id() == CrayonLangs::DEFAULT_LANG) {
232
- break;
233
- }
234
- // Falls through
235
- case 1 :
236
- $print_lang = '<span class="crayon-language">' . $lang . '</span>';
237
- break;
238
- }
239
- }
240
- // Disable functionality for errors
241
- $error = $hl->error();
242
- // Combined settings for code
243
- $code_settings = '';
244
- // Disable mouseover for touchscreen devices and mobiles, if we are told to
245
- $touch = FALSE; // Whether we have detected a touchscreen device
246
- if ($hl->setting_val(CrayonSettings::TOUCHSCREEN) && CrayonUtil::is_touch()) {
247
- $touch = TRUE;
248
- $code_settings .= ' touchscreen';
249
- }
250
-
251
- // Disabling Popup
252
- if (!$hl->setting_val(CrayonSettings::POPUP)) {
253
- $code_settings .= ' no-popup';
254
- }
255
 
256
  // Minimize
257
  if (!$hl->setting_val(CrayonSettings::MINIMIZE)) {
258
  $code_settings .= ' minimize';
259
  }
260
 
261
- // Draw the plain code and toolbar
262
- $toolbar_settings = $print_plain_button = $print_copy_button = '';
263
  $toolbar_index = $hl->setting_index(CrayonSettings::TOOLBAR);
264
- if (empty($error) && ($toolbar_index != 2 || $hl->setting_val(CrayonSettings::MINIMIZE))) {
265
- // Enable mouseover setting for toolbar
266
- if ($toolbar_index == 0 && !$touch) {
267
- // No touchscreen detected
268
- $toolbar_settings .= ' mouseover';
269
- if ($hl->setting_val(CrayonSettings::TOOLBAR_OVERLAY)) {
270
- $toolbar_settings .= ' overlay';
271
- }
272
- if ($hl->setting_val(CrayonSettings::TOOLBAR_HIDE)) {
273
- $toolbar_settings .= ' hide';
274
- }
275
- if ($hl->setting_val(CrayonSettings::TOOLBAR_DELAY)) {
276
- $toolbar_settings .= ' delay';
277
- }
278
- } else if ($toolbar_index == 1) {
279
- // Always display the toolbar
280
- $toolbar_settings .= ' show';
281
- } else if ($toolbar_index == 2) {
282
- $toolbar_settings .= ' never-show';
283
- }
284
-
285
- $buttons = array();
286
-
287
- if ($hl->setting_val(CrayonSettings::NUMS_TOGGLE)) {
288
- $buttons['nums'] = crayon__('Toggle Line Numbers');
289
- }
290
-
291
- if ($hl->setting_val(CrayonSettings::PLAIN) && $hl->setting_val(CrayonSettings::PLAIN_TOGGLE)) {
292
- $buttons['plain'] = crayon__('Toggle Plain Code');
293
- }
294
-
295
- if ($hl->setting_val(CrayonSettings::WRAP_TOGGLE)) {
296
- $buttons['wrap'] = crayon__('Toggle Line Wrap');
297
- }
298
-
299
- if ($hl->setting_val(CrayonSettings::EXPAND_TOGGLE)) {
300
- $buttons['expand'] = crayon__('Expand Code');
301
- }
302
-
303
- if (!$touch && $hl->setting_val(CrayonSettings::PLAIN) && $hl->setting_val(CrayonSettings::COPY)) {
304
- $buttons['copy'] = crayon__('Copy');
305
- }
306
-
307
- if ($hl->setting_val(CrayonSettings::POPUP)) {
308
- $buttons['popup'] = crayon__('Open Code In New Window');
309
- }
310
-
311
- $buttons_str = '';
312
- foreach ($buttons as $button=>$value) {
313
- $buttons_str .= '<div class="crayon-button crayon-' . $button . '-button"';
314
- if (!is_array($value)) {
315
- $value = array('title' => $value);
316
- }
317
- foreach ($value as $k=>$v) {
318
- $buttons_str .= ' ' . $k . '="' . $v . '"';
319
- }
320
- $buttons_str .= '><div class="crayon-button-icon"></div></div>';
321
- }
322
-
323
- /* The table is rendered invisible by CSS and enabled with JS when asked to. If JS
324
- is not enabled or fails, the toolbar won't work so there is no point to display it. */
325
- $print_plus = $hl->is_mixed() && $hl->setting_val(CrayonSettings::SHOW_MIXED) ? '<span class="crayon-mixed-highlight" title="'.crayon__('Contains Mixed Languages').'"></span>' : '';
326
- $buttons = $print_plus.$buttons_str.$print_lang;
327
- $toolbar = '
328
- <div class="crayon-toolbar" data-settings="'.$toolbar_settings.'" style="'.$toolbar_style.'">'.$print_title.'
329
- <div class="crayon-tools" style="'.$toolbar_style.'">'.$buttons.'</div></div>
330
- <div class="crayon-info" style="'.$info_style.'"></div>';
331
-
332
- } else {
333
- $toolbar = $buttons = $plain_settings = '';
334
- }
335
-
336
- if (empty($error) && $hl->setting_val(CrayonSettings::PLAIN)) {
337
- // Different events to display plain code
338
- switch ($hl->setting_index(CrayonSettings::SHOW_PLAIN)) {
339
- case 0 :
340
- $plain_settings = 'dblclick';
341
- break;
342
- case 1 :
343
- $plain_settings = 'click';
344
- break;
345
- case 2 :
346
- $plain_settings = 'mouseover';
347
- break;
348
- default :
349
- $plain_settings = '';
350
- }
351
- if ($hl->setting_val(CrayonSettings::SHOW_PLAIN_DEFAULT)) {
352
- $plain_settings .= ' show-plain-default';
353
- }
354
- $readonly = $touch ? '' : 'readonly';
355
- $print_plain = $print_plain_button = '';
356
- $textwrap = !$hl->setting_val(CrayonSettings::WRAP) ? 'wrap="soft"' : '';
357
- $print_plain = '<textarea '.$textwrap.' class="crayon-plain print-no" data-settings="' . $plain_settings . '" '. $readonly .' style="' . $pre_style .' '. $font_style . '">' . "\n" . self::clean_code($hl->code()) . '</textarea>';
358
- } else {
359
- $print_plain = $plain_settings = $plain_settings = '';
360
- }
361
-
362
- // Line numbers visibility
363
- $num_vis = $num_settings = '';
364
- if ($line_numbers === FALSE) {
365
- $num_vis = 'crayon-invisible';
366
- } else {
367
- $num_settings = ($hl->setting_val(CrayonSettings::NUMS) ? 'show' : 'hide');
368
- }
369
-
370
- // Determine scrollbar visibility
371
- $code_settings .= $hl->setting_val(CrayonSettings::SCROLL) && !$touch ? ' scroll-always' : ' scroll-mouseover';
372
-
373
- // Disable animations
374
- if ($hl->setting_val(CrayonSettings::DISABLE_ANIM)) {
375
- $code_settings .= ' disable-anim';
376
- }
377
-
378
- // Wrap
379
- if ($hl->setting_val(CrayonSettings::WRAP)) {
380
- $code_settings .= ' wrap';
381
- }
382
-
383
- // Expand
384
- if ($hl->setting_val(CrayonSettings::EXPAND)) {
385
- $code_settings .= ' expand';
386
- }
387
-
388
- // Determine dimensions
389
- if ($hl->setting_val(CrayonSettings::HEIGHT_SET)) {
390
- $height_style = self::dimension_style($hl, CrayonSettings::HEIGHT);
391
- // XXX Only set height for main, not code (if toolbar always visible, code will cover main)
392
- if ($hl->setting_index(CrayonSettings::HEIGHT_UNIT) == 0) {
393
- $main_style .= $height_style;
394
- }
395
- }
396
- if ($hl->setting_val(CrayonSettings::WIDTH_SET)) {
397
- $width_style = self::dimension_style($hl, CrayonSettings::WIDTH);
398
- $code_style .= $width_style;
399
- if ($hl->setting_index(CrayonSettings::WIDTH_UNIT) == 0) {
400
- $main_style .= $width_style;
401
- }
402
- }
403
-
404
- // Determine margins
405
- if ($hl->setting_val(CrayonSettings::TOP_SET)) {
406
- $code_style .= ' margin-top: ' . $hl->setting_val(CrayonSettings::TOP_MARGIN) . 'px;';
407
- }
408
- if ($hl->setting_val(CrayonSettings::BOTTOM_SET)) {
409
- $code_style .= ' margin-bottom: ' . $hl->setting_val(CrayonSettings::BOTTOM_MARGIN) . 'px;';
410
- }
411
- if ($hl->setting_val(CrayonSettings::LEFT_SET)) {
412
- $code_style .= ' margin-left: ' . $hl->setting_val(CrayonSettings::LEFT_MARGIN) . 'px;';
413
- }
414
- if ($hl->setting_val(CrayonSettings::RIGHT_SET)) {
415
- $code_style .= ' margin-right: ' . $hl->setting_val(CrayonSettings::RIGHT_MARGIN) . 'px;';
416
- }
417
-
418
- // Determine horizontal alignment
419
- $align_style = '';
420
- switch ($hl->setting_index(CrayonSettings::H_ALIGN)) {
421
- case 1 :
422
- $align_style = ' float: left;';
423
- break;
424
- case 2 :
425
- $align_style = ' float: none; margin-left: auto; margin-right: auto;';
426
- break;
427
- case 3 :
428
- $align_style = ' float: right;';
429
- break;
430
- }
431
- $code_style .= $align_style;
432
-
433
- // Determine allowed float elements
434
- if ($hl->setting_val(CrayonSettings::FLOAT_ENABLE)) {
435
- $clear_style = ' clear: none;';
436
- } else {
437
  $clear_style = '';
438
  }
439
- $code_style .= $clear_style;
440
 
441
- // Determine if operating system is mac
442
- $crayon_os = CrayonUtil::is_mac() ? 'mac' : 'pc';
443
 
444
- // Produce output
445
- $output .= '
446
- <div id="'.$uid.'" class="crayon-syntax crayon-theme-'.$theme_id_dashed.' crayon-font-'.$font_id_dashed.' crayon-os-'.$crayon_os.' print-yes notranslate" data-settings="'.$code_settings.'" style="'.$code_style.' '.$font_style.'">
447
- '.$toolbar.'
448
- <div class="crayon-plain-wrap">'.$print_plain.'</div>'.'
449
- <div class="crayon-main" style="'.$main_style.'">
450
  <table class="crayon-table">
451
  <tr class="crayon-row">';
452
 
453
- if ($print_nums !== FALSE) {
454
- $output .= '
455
- <td class="crayon-nums '.$num_vis.'" data-settings="'.$num_settings.'">
456
- <div class="crayon-nums-content" style="'.$font_style.'">'.$print_nums.'</div>
457
  </td>';
458
- }
459
- // XXX
460
- $output .= '
461
- <td class="crayon-code"><div class="crayon-pre" style="'.$font_style.' '.$pre_style.'">'.$print_code.'</div></td>
462
  </tr>
463
  </table>
464
  </div>
465
  </div>';
466
- // Debugging stats
467
- $runtime = $hl->runtime();
468
- if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
469
- $output = '<!-- Crayon Syntax Highlighter v' . $CRAYON_VERSION . ' -->'
470
- . CRAYON_NL . $output . CRAYON_NL . '<!-- ';
471
- foreach ($hl->runtime() as $type => $time) {
472
- $output .= '[' . $type . ': ' . sprintf('%.4f seconds', $time) . '] ';
473
- }
474
- $output .= '-->' . CRAYON_NL;
475
- }
476
- // Determine whether to print to screen or save
477
- if ($print) {
478
- echo $output;
479
- } else {
480
- return $output;
481
- }
482
- }
483
-
484
- public static function print_error($hl, $error, $line_numbers = 'ERROR', $print = TRUE) {
485
- if (get_class($hl) != CRAYON_HIGHLIGHTER) {
486
- return;
487
- }
488
- // Either print the error returned by the handler, or a custom error message
489
- if ($hl->setting_val(CrayonSettings::ERROR_MSG_SHOW)) {
490
- $error = $hl->setting_val(CrayonSettings::ERROR_MSG);
491
- }
492
- $error = self::split_lines(trim($error), 'crayon-error');
493
- return self::print_code($hl, $error, $line_numbers, $print);
494
- }
495
-
496
- // Delimiters =============================================================
497
-
498
- public static function format_mixed_code($code, $language, $hl) {
499
- self::$curr = $hl;
500
- self::$delim_pieces = array();
501
- // Remove crayon internal element from INPUT code
502
- $code = preg_replace('#'.CrayonParser::CRAYON_ELEMENT_REGEX_CAPTURE.'#msi', '', $code);
503
-
504
- if (self::$delimiters == NULL) {
505
- self::$delimiters = CrayonResources::langs()->delimiters();
506
- }
507
-
508
- // Find all delimiters in all languages
509
- if (self::$delim_regex == NULL) {
510
- self::$delim_regex = '#(' . implode(')|(', array_values(self::$delimiters)) . ')#msi';
511
- }
512
-
513
- // Extract delimited code, replace with internal elements
514
- $internal_code = preg_replace_callback(self::$delim_regex, 'CrayonFormatter::delim_to_internal', $code);
515
-
516
- // Format with given language
517
- $formatted_code = CrayonFormatter::format_code($internal_code, $language, $hl);
518
-
519
- // Replace internal elements with delimited pieces
520
- $formatted_code = preg_replace_callback('#\{\{crayon-internal:(\d+)\}\}#', 'CrayonFormatter::internal_to_code', $formatted_code);
521
-
522
- return $formatted_code;
523
- }
524
-
525
- public static function delim_to_internal($matches) {
526
- // Mark as mixed so we can show (+)
527
- self::$curr->is_mixed(TRUE);
528
- $capture_group = count($matches) - 2;
529
- $capture_groups = array_keys(self::$delimiters);
530
- $lang_id = $capture_groups[$capture_group];
531
- if ( ($lang = CrayonResources::langs()->get($lang_id)) === NULL ) {
532
- return $matches[0];
533
- }
534
- $internal = sprintf('{{crayon-internal:%d}}', count(self::$delim_pieces));
535
- // TODO fix
536
- self::$delim_pieces[] = CrayonFormatter::format_code($matches[0], $lang, self::$curr);
537
- return $internal;
538
- }
539
-
540
- public static function internal_to_code($matches) {
541
- return self::$delim_pieces[intval($matches[1])];
542
- }
543
-
544
- // Auxiliary Methods ======================================================
545
- /* Prepares code for formatting. */
546
- public static function clean_code($code, $escape = TRUE, $spaces = FALSE, $tabs = FALSE, $lines = FALSE) {
547
- if (empty($code)) {
548
- return $code;
549
- }
550
- /* Convert <, > and & characters to entities, as these can appear as HTML tags and entities. */
551
- if ($escape) {
552
- $code = CrayonUtil::htmlspecialchars($code);
553
- }
554
- if ($spaces) {
555
- // Replace 2 spaces with html escaped characters
556
- $code = preg_replace('#[ ]{2}#msi', '&nbsp;&nbsp;', $code);
557
- }
558
- if ($tabs && CrayonGlobalSettings::val(CrayonSettings::TAB_CONVERT)) {
559
- // Replace tabs with 4 spaces
560
- $code = preg_replace('#\t#', str_repeat('&nbsp;', CrayonGlobalSettings::val(CrayonSettings::TAB_SIZE)), $code);
561
- }
562
- if ($lines) {
563
- $code = preg_replace('#(\r\n)|\r|\n#msi', "\r\n", $code);
564
- }
565
- return $code;
566
- }
567
-
568
- /* Converts the code to entities and wraps in a <pre><code></code></pre> */
569
- public static function plain_code($code, $encoded = TRUE) {
570
- if (is_array($code)) {
571
- // When used as a preg_replace_callback
572
- $code = $code[1];
573
- }
574
- if (!$encoded) {
575
- $code = CrayonUtil::htmlentities($code);
576
- }
577
- if (CrayonGlobalSettings::val(CrayonSettings::TRIM_WHITESPACE)) {
578
- $code = trim($code);
579
- }
580
- return '<pre class="crayon-plain-tag">'.$code.'</pre>';
581
- }
582
-
583
- public static function split_lines($code, $class) {
584
- $code = self::clean_code($code, TRUE, TRUE, TRUE, FALSE);
585
  $class = preg_replace('#(\w+)#m', 'crayon-$1', $class);
586
- $code = preg_replace('#^([^\r\n]+)(?=\r\n|\r|\n|$)#m', '<span class="'.$class.'">$1</span>', $code);
587
- return $code;
588
- }
589
-
590
- private static function dimension_style($hl, $name) {
591
- $mode = $unit = '';
592
- switch ($name) {
593
- case CrayonSettings::HEIGHT :
594
- $mode = CrayonSettings::HEIGHT_MODE;
595
- $unit = CrayonSettings::HEIGHT_UNIT;
596
- break;
597
- case CrayonSettings::WIDTH :
598
- $mode = CrayonSettings::WIDTH_MODE;
599
- $unit = CrayonSettings::WIDTH_UNIT;
600
- break;
601
- }
602
- // XXX Uses actual index value to identify options
603
- $mode = $hl->setting_index($mode);
604
- $unit = $hl->setting_index($unit);
605
- $dim_mode = $dim_unit = '';
606
- if ($mode !== FALSE) {
607
- switch ($mode) {
608
- case 0 :
609
- $dim_mode .= 'max-';
610
- break;
611
- case 1 :
612
- $dim_mode .= 'min-';
613
- break;
614
- }
615
- }
616
- $dim_mode .= $name;
617
- if ($unit !== FALSE) {
618
- switch ($unit) {
619
- case 0 :
620
- $dim_unit = 'px';
621
- break;
622
- case 1 :
623
- $dim_unit = '%';
624
- break;
625
- }
626
- }
627
- return ' ' . $dim_mode . ': ' . $hl->setting_val($name) . $dim_unit . ';';
628
- }
629
  }
 
630
  ?>
1
  <?php
2
+ require_once('global.php');
3
+ require_once(CRAYON_HIGHLIGHTER_PHP);
4
+ require_once(CRAYON_SETTINGS_PHP);
5
+ require_once(CRAYON_PARSER_PHP);
6
+ require_once(CRAYON_THEMES_PHP);
7
 
8
  /* Manages formatting the html with html and css. */
9
+
10
  class CrayonFormatter {
11
+ // Properties and Constants ===============================================
12
+ /* Used to temporarily store the array of CrayonElements passed to format_code(), so that
13
+ format_matches() can access them and identify which elements were captured and format
14
+ accordingly. This must be static for preg_replace_callback() to access it.*/
15
+ private static $elements = array();
16
+
17
+ // Delimiters
18
+ // Current crayon undergoing delimiter replace
19
+ private static $curr;
20
+ private static $delimiters;
21
+ private static $delim_regex;
22
+ private static $delim_pieces;
23
+
24
+ // Methods ================================================================
25
+ private function __construct() {
26
+ }
27
+
28
+ /* Formats the code using the parsed language elements. */
29
+ public static function format_code($code, $language, $hl = NULL) {
30
+ // Ensure the language is defined
31
+ if ($language != NULL && $hl->is_highlighted()) {
32
+ $code = self::clean_code($code, FALSE, FALSE, FALSE, TRUE);
33
+ /* Perform the replace on the code using the regex, pass the captured matches for
34
+ formatting before they are replaced */
35
+ try {
36
+ CrayonParser::parse($language->id());
37
+ // Match language regex
38
+ $elements = $language->elements();
39
+ $regex = $language->regex();
40
+ if (!empty($regex) && !empty($elements)) {
41
+ // Get array of CrayonElements
42
+ self::$elements = array_values($elements);
43
+ $code = preg_replace_callback($regex, 'CrayonFormatter::format_match', $code);
44
+ }
45
+ } catch (Exception $e) {
46
+ $error = 'An error occured when formatting: ' . $e->message();
47
+ $hl ? $hl->log($error) : CrayonLog::syslog($error);
48
+ }
49
+ return $code;
50
+ } else {
51
+ return self::clean_code($code, TRUE, TRUE, TRUE, TRUE);
52
+ }
53
+ }
54
+
55
+ /* Performs a replace to format each match based on the captured element. */
56
+ private static function format_match($matches) {
57
+ /* First index in $matches is full match, subsequent indices are groups.
58
+ * Minimum number of elements in array is 2, so minimum captured group is 0. */
59
+ $captured_group_number = count($matches) - 2;
60
+ $code = $matches[0];
61
+ if (array_key_exists($captured_group_number, self::$elements)) {
62
+ $captured_element = self::$elements[$captured_group_number];
63
+ // Avoid capturing and formatting internal Crayon elements
64
+ if ($captured_element->name() == CrayonParser::CRAYON_ELEMENT) {
65
+ return $code; // Return as is
66
+ } else {
67
+ // Separate lines and add css class, keep extended class last to allow overriding
68
+ $fallback_css = CrayonLangs::known_elements($captured_element->fallback());
69
+ $element_css = $captured_element->css();
70
+ $css = !empty($fallback_css) ? $fallback_css . ' ' . $element_css : $element_css;
71
+ return self::split_lines($code, $css);
72
+ }
73
+ } else {
74
+ // All else fails, return the match
75
+ return $matches[0];
76
+ }
77
+ }
78
+
79
+ /* Prints the formatted code, option to override the line numbers with a custom string */
80
+ public static function print_code($hl, $code, $line_numbers = TRUE, $print = TRUE) {
81
+ global $CRAYON_VERSION;
82
+
83
+ // We can print either block or inline, inline is treated differently, factor out common stuff here
84
+ $output = '';
85
+ // Used for style tag
86
+ $main_style = $code_style = $toolbar_style = $info_style = $font_style = $line_style = $pre_style = '';
87
+ // Unique ID for this instance of Crayon
88
+ $uid = 'crayon-' . $hl->id();
89
+ // Print theme id
90
+ // We make the assumption that the id is correct (checked in crayon_wp)
91
+ $theme_id = $hl->setting_val(CrayonSettings::THEME);
92
+ $theme_id_dashed = CrayonUtil::space_to_hyphen($theme_id);
93
+ if (!$hl->setting_val(CrayonSettings::ENQUEUE_THEMES)) {
94
+ $output .= CrayonResources::themes()->get_css($theme_id);
95
+ }
96
+
97
+ // Print font id
98
+ // We make the assumption that the id is correct (checked in crayon_wp)
99
+ $font_id = $hl->setting_val(CrayonSettings::FONT);
100
+ $font_id_dashed = CrayonUtil::space_to_hyphen($font_id);
101
+ if (!$hl->setting_val(CrayonSettings::ENQUEUE_FONTS)) {
102
+ $output .= CrayonResources::fonts()->get_css($font_id);
103
+ }
104
+
105
+ // Inline margin
106
+ if ($hl->is_inline()) {
107
+ $inline_margin = $hl->setting_val(CrayonSettings::INLINE_MARGIN) . 'px !important;';
108
+ }
109
+
110
+ // Determine font size
111
+ // TODO improve logic
112
+ if ($hl->setting_val(CrayonSettings::FONT_SIZE_ENABLE)) {
113
  $_font_size = $hl->setting_val(CrayonSettings::FONT_SIZE);
114
+ $font_size = $_font_size . 'px !important;';
115
  $_line_height = $hl->setting_val(CrayonSettings::LINE_HEIGHT);
116
  // Don't allow line height to be less than font size
117
  $line_height = ($_line_height > $_font_size ? $_line_height : $_font_size) . 'px !important;';
118
+ $toolbar_height = $font_size * 1.5 . 'px !important;';
119
+ $info_height = $font_size * 1.4 . 'px !important;';
120
 
121
+ $font_style .= "font-size: $font_size line-height: $line_height";
122
  $toolbar_style .= "font-size: $font_size";
123
+ $line_style .= "height: $line_height";
124
+
125
+ if ($hl->is_inline()) {
126
+ $font_style .= "font-size: $font_size";
127
+ } else {
128
+ $toolbar_style .= "height: $toolbar_height line-height: $toolbar_height";
129
+ $info_style .= "min-height: $info_height line-height: $info_height";
130
+ }
131
+ } else if (!$hl->is_inline()) {
132
+ if (($font_size = CrayonGlobalSettings::get(CrayonSettings::FONT_SIZE)) !== FALSE) {
133
+ $font_size = $font_size->def() . 'px !important;';
134
  $line_height = ($font_size * 1.4) . 'px !important;';
135
+ }
136
+ }
137
 
138
  $tab = $hl->setting_val(CrayonSettings::TAB_SIZE);
139
  $pre_style = "-moz-tab-size:$tab; -o-tab-size:$tab; -webkit-tab-size:$tab; tab-size:$tab;";
140
 
141
+ // This will return from function with inline print
142
+ if ($hl->is_inline()) {
143
+ $wrap = !$hl->setting_val(CrayonSettings::INLINE_WRAP) ? 'crayon-syntax-inline-nowrap' : '';
144
+ $output .= '
145
+ <span id="' . $uid . '" class="crayon-syntax crayon-syntax-inline ' . $wrap . ' crayon-theme-' . $theme_id_dashed . ' crayon-theme-' . $theme_id_dashed . '-inline crayon-font-' . $font_id_dashed . '" style="' . $font_style . '">' .
146
+ '<span class="crayon-pre crayon-code" style="' . $font_style . ' ' . $pre_style . '">' . $code . '</span>' .
147
+ '</span>';
148
+ return $output;
149
+ }
150
+
151
+ // Below code only for block (default) printing
152
+
153
+ // Generate the code lines and separate each line as a div
154
+ $print_code = '';
155
+ $print_nums = '';
156
+ $hl->line_count(preg_match_all("#(?:^|(?<=\r\n|\n))[^\r\n]*#", $code, $code_lines));
157
+
158
+ // The line number to start from
159
+ $start_line = $hl->setting_val(CrayonSettings::START_LINE);
160
+ $marking = $hl->setting_val(CrayonSettings::MARKING);
161
+ $striped = $hl->setting_val(CrayonSettings::STRIPED);
162
+ $range = $hl->setting_val(CrayonSettings::RANGES) ? $hl->range() : FALSE;
163
+ for ($i = 1; $i <= $hl->line_count(); $i++) {
164
+ // Check if the current line is in the range of code to display
165
+ if ($range) {
166
+ if ($i < $range[0]) {
167
+ continue;
168
+ } else if ($i > $range[1]) {
169
+ break;
170
+ }
171
+ }
172
+ $code_line = $code_lines[0][$i - 1];
173
+
174
+ // If line is blank, add a space so the div has the correct height
175
+ if ($code_line == '') {
176
+ $code_line = '&nbsp;';
177
+ }
178
+
179
+ // Check if the current line has been selected
180
+ $marked_lines = $hl->marked();
181
+ // Check if lines need to be marked as important
182
+ if ($marking && in_array($i, $marked_lines)) {
183
+ $marked_num = ' crayon-marked-num';
184
+ $marked_line = ' crayon-marked-line';
185
+ // If multiple lines are marked, only show borders for top and bottom lines
186
+ if (!in_array($i - 1, $marked_lines)) {
187
+ $marked_num .= ' crayon-top';
188
+ $marked_line .= ' crayon-top';
189
+ }
190
+ // Single lines are both the top and bottom of the multiple marked lines
191
+ if (!in_array($i + 1, $marked_lines)) {
192
+ $marked_num .= ' crayon-bottom';
193
+ $marked_line .= ' crayon-bottom';
194
+ }
195
+ } else {
196
+ $marked_num = $marked_line = '';
197
+ }
198
+ // Stripe odd lines
199
+ if ($striped && $i % 2 == 0) {
200
+ $striped_num = ' crayon-striped-num';
201
+ $striped_line = ' crayon-striped-line';
202
+ } else {
203
+ $striped_num = $striped_line = '';
204
+ }
205
+ // Generate the lines
206
+ $line_num = $start_line + $i - 1;
207
+ $line_id = $uid . '-' . $line_num;
208
+ $print_code .= '<div class="crayon-line' . $marked_line . $striped_line . '" id="' . $line_id . '">' . $code_line . '</div>';
209
+ if (!is_string($line_numbers)) {
210
+ $print_nums .= '<div class="crayon-num' . $marked_num . $striped_num . '" data-line="' . $line_id . '">' . $line_num . '</div>';
211
+ }
212
+ }
213
+ // If $line_numbers is a string, display it
214
+ if (is_string($line_numbers) && !empty($line_numbers)) {
215
+ $print_nums .= '<div class="crayon-num">' . $line_numbers . '</div>';
216
+ } else if (empty($line_numbers)) {
217
+ $print_nums = FALSE;
218
+ }
219
+ // Determine whether to print title, encode characters
220
+ $title = $hl->title();
221
+ // Decode if needed
222
+ if ($hl->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
223
+ $title = CrayonUtil::html_entity_decode($title);
224
+ }
225
+ $print_title = '<span class="crayon-title">' . $title . '</span>';
226
+ // Determine whether to print language
227
+ $print_lang = '';
228
+ // XXX Use for printing the regex
229
+ if ($hl->language()) {
230
+ $lang = $hl->language()->name();
231
+ switch ($hl->setting_index(CrayonSettings::SHOW_LANG)) {
232
+ case 0 :
233
+ if ($hl->language()->id() == CrayonLangs::DEFAULT_LANG) {
234
+ break;
235
+ }
236
+ // Falls through
237
+ case 1 :
238
+ $print_lang = '<span class="crayon-language">' . $lang . '</span>';
239
+ break;
240
+ }
241
+ }
242
+ // Disable functionality for errors
243
+ $error = $hl->error();
244
+ // Combined settings for code
245
+ $code_settings = '';
246
+ // Disable mouseover for touchscreen devices and mobiles, if we are told to
247
+ $touch = FALSE; // Whether we have detected a touchscreen device
248
+ if ($hl->setting_val(CrayonSettings::TOUCHSCREEN) && CrayonUtil::is_touch()) {
249
+ $touch = TRUE;
250
+ $code_settings .= ' touchscreen';
251
+ }
252
+
253
+ // Disabling Popup
254
+ if (!$hl->setting_val(CrayonSettings::POPUP)) {
255
+ $code_settings .= ' no-popup';
256
+ }
257
 
258
  // Minimize
259
  if (!$hl->setting_val(CrayonSettings::MINIMIZE)) {
260
  $code_settings .= ' minimize';
261
  }
262
 
263
+ // Draw the plain code and toolbar
264
+ $toolbar_settings = $print_plain_button = $print_copy_button = '';
265
  $toolbar_index = $hl->setting_index(CrayonSettings::TOOLBAR);
266
+ if (empty($error) && ($toolbar_index != 2 || $hl->setting_val(CrayonSettings::MINIMIZE))) {
267
+ // Enable mouseover setting for toolbar
268
+ if ($toolbar_index == 0 && !$touch) {
269
+ // No touchscreen detected
270
+ $toolbar_settings .= ' mouseover';
271
+ if ($hl->setting_val(CrayonSettings::TOOLBAR_OVERLAY)) {
272
+ $toolbar_settings .= ' overlay';
273
+ }
274
+ if ($hl->setting_val(CrayonSettings::TOOLBAR_HIDE)) {
275
+ $toolbar_settings .= ' hide';
276
+ }
277
+ if ($hl->setting_val(CrayonSettings::TOOLBAR_DELAY)) {
278
+ $toolbar_settings .= ' delay';
279
+ }
280
+ } else if ($toolbar_index == 1) {
281
+ // Always display the toolbar
282
+ $toolbar_settings .= ' show';
283
+ } else if ($toolbar_index == 2) {
284
+ $toolbar_settings .= ' never-show';
285
+ }
286
+
287
+ $buttons = array();
288
+
289
+ if ($hl->setting_val(CrayonSettings::NUMS_TOGGLE)) {
290
+ $buttons['nums'] = crayon__('Toggle Line Numbers');
291
+ }
292
+
293
+ if ($hl->setting_val(CrayonSettings::PLAIN) && $hl->setting_val(CrayonSettings::PLAIN_TOGGLE)) {
294
+ $buttons['plain'] = crayon__('Toggle Plain Code');
295
+ }
296
+
297
+ if ($hl->setting_val(CrayonSettings::WRAP_TOGGLE)) {
298
+ $buttons['wrap'] = crayon__('Toggle Line Wrap');
299
+ }
300
+
301
+ if ($hl->setting_val(CrayonSettings::EXPAND_TOGGLE)) {
302
+ $buttons['expand'] = crayon__('Expand Code');
303
+ }
304
+
305
+ if (!$touch && $hl->setting_val(CrayonSettings::PLAIN) && $hl->setting_val(CrayonSettings::COPY)) {
306
+ $buttons['copy'] = crayon__('Copy');
307
+ }
308
+
309
+ if ($hl->setting_val(CrayonSettings::POPUP)) {
310
+ $buttons['popup'] = crayon__('Open Code In New Window');
311
+ }
312
+
313
+ $buttons_str = '';
314
+ foreach ($buttons as $button => $value) {
315
+ $buttons_str .= '<div class="crayon-button crayon-' . $button . '-button"';
316
+ if (!is_array($value)) {
317
+ $value = array('title' => $value);
318
+ }
319
+ foreach ($value as $k => $v) {
320
+ $buttons_str .= ' ' . $k . '="' . $v . '"';
321
+ }
322
+ $buttons_str .= '><div class="crayon-button-icon"></div></div>';
323
+ }
324
+
325
+ /* The table is rendered invisible by CSS and enabled with JS when asked to. If JS
326
+ is not enabled or fails, the toolbar won't work so there is no point to display it. */
327
+ $print_plus = $hl->is_mixed() && $hl->setting_val(CrayonSettings::SHOW_MIXED) ? '<span class="crayon-mixed-highlight" title="' . crayon__('Contains Mixed Languages') . '"></span>' : '';
328
+ $buttons = $print_plus . $buttons_str . $print_lang;
329
+ $toolbar = '
330
+ <div class="crayon-toolbar" data-settings="' . $toolbar_settings . '" style="' . $toolbar_style . '">' . $print_title . '
331
+ <div class="crayon-tools" style="' . $toolbar_style . '">' . $buttons . '</div></div>
332
+ <div class="crayon-info" style="' . $info_style . '"></div>';
333
+
334
+ } else {
335
+ $toolbar = $buttons = $plain_settings = '';
336
+ }
337
+
338
+ if (empty($error) && $hl->setting_val(CrayonSettings::PLAIN)) {
339
+ // Different events to display plain code
340
+ switch ($hl->setting_index(CrayonSettings::SHOW_PLAIN)) {
341
+ case 0 :
342
+ $plain_settings = 'dblclick';
343
+ break;
344
+ case 1 :
345
+ $plain_settings = 'click';
346
+ break;
347
+ case 2 :
348
+ $plain_settings = 'mouseover';
349
+ break;
350
+ default :
351
+ $plain_settings = '';
352
+ }
353
+ if ($hl->setting_val(CrayonSettings::SHOW_PLAIN_DEFAULT)) {
354
+ $plain_settings .= ' show-plain-default';
355
+ }
356
+ $readonly = $touch ? '' : 'readonly';
357
+ $print_plain = $print_plain_button = '';
358
+ $textwrap = !$hl->setting_val(CrayonSettings::WRAP) ? 'wrap="soft"' : '';
359
+ $print_plain = '<textarea ' . $textwrap . ' class="crayon-plain print-no" data-settings="' . $plain_settings . '" ' . $readonly . ' style="' . $pre_style . ' ' . $font_style . '">' . "\n" . self::clean_code($hl->code()) . '</textarea>';
360
+ } else {
361
+ $print_plain = $plain_settings = $plain_settings = '';
362
+ }
363
+
364
+ // Line numbers visibility
365
+ $num_vis = $num_settings = '';
366
+ if ($line_numbers === FALSE) {
367
+ $num_vis = 'crayon-invisible';
368
+ } else {
369
+ $num_settings = ($hl->setting_val(CrayonSettings::NUMS) ? 'show' : 'hide');
370
+ }
371
+
372
+ // Determine scrollbar visibility
373
+ $code_settings .= $hl->setting_val(CrayonSettings::SCROLL) && !$touch ? ' scroll-always' : ' scroll-mouseover';
374
+
375
+ // Disable animations
376
+ if ($hl->setting_val(CrayonSettings::DISABLE_ANIM)) {
377
+ $code_settings .= ' disable-anim';
378
+ }
379
+
380
+ // Wrap
381
+ if ($hl->setting_val(CrayonSettings::WRAP)) {
382
+ $code_settings .= ' wrap';
383
+ }
384
+
385
+ // Expand
386
+ if ($hl->setting_val(CrayonSettings::EXPAND)) {
387
+ $code_settings .= ' expand';
388
+ }
389
+
390
+ // Determine dimensions
391
+ if ($hl->setting_val(CrayonSettings::HEIGHT_SET)) {
392
+ $height_style = self::dimension_style($hl, CrayonSettings::HEIGHT);
393
+ // XXX Only set height for main, not code (if toolbar always visible, code will cover main)
394
+ if ($hl->setting_index(CrayonSettings::HEIGHT_UNIT) == 0) {
395
+ $main_style .= $height_style;
396
+ }
397
+ }
398
+ if ($hl->setting_val(CrayonSettings::WIDTH_SET)) {
399
+ $width_style = self::dimension_style($hl, CrayonSettings::WIDTH);
400
+ $code_style .= $width_style;
401
+ if ($hl->setting_index(CrayonSettings::WIDTH_UNIT) == 0) {
402
+ $main_style .= $width_style;
403
+ }
404
+ }
405
+
406
+ // Determine margins
407
+ if ($hl->setting_val(CrayonSettings::TOP_SET)) {
408
+ $code_style .= ' margin-top: ' . $hl->setting_val(CrayonSettings::TOP_MARGIN) . 'px;';
409
+ }
410
+ if ($hl->setting_val(CrayonSettings::BOTTOM_SET)) {
411
+ $code_style .= ' margin-bottom: ' . $hl->setting_val(CrayonSettings::BOTTOM_MARGIN) . 'px;';
412
+ }
413
+ if ($hl->setting_val(CrayonSettings::LEFT_SET)) {
414
+ $code_style .= ' margin-left: ' . $hl->setting_val(CrayonSettings::LEFT_MARGIN) . 'px;';
415
+ }
416
+ if ($hl->setting_val(CrayonSettings::RIGHT_SET)) {
417
+ $code_style .= ' margin-right: ' . $hl->setting_val(CrayonSettings::RIGHT_MARGIN) . 'px;';
418
+ }
419
+
420
+ // Determine horizontal alignment
421
+ $align_style = '';
422
+ switch ($hl->setting_index(CrayonSettings::H_ALIGN)) {
423
+ case 1 :
424
+ $align_style = ' float: left;';
425
+ break;
426
+ case 2 :
427
+ $align_style = ' float: none; margin-left: auto; margin-right: auto;';
428
+ break;
429
+ case 3 :
430
+ $align_style = ' float: right;';
431
+ break;
432
+ }
433
+ $code_style .= $align_style;
434
+
435
+ // Determine allowed float elements
436
+ if ($hl->setting_val(CrayonSettings::FLOAT_ENABLE)) {
437
+ $clear_style = ' clear: none;';
438
+ } else {
439
  $clear_style = '';
440
  }
441
+ $code_style .= $clear_style;
442
 
443
+ // Determine if operating system is mac
444
+ $crayon_os = CrayonUtil::is_mac() ? 'mac' : 'pc';
445
 
446
+ // Produce output
447
+ $output .= '
448
+ <div id="' . $uid . '" class="crayon-syntax crayon-theme-' . $theme_id_dashed . ' crayon-font-' . $font_id_dashed . ' crayon-os-' . $crayon_os . ' print-yes notranslate" data-settings="' . $code_settings . '" style="' . $code_style . ' ' . $font_style . '">
449
+ ' . $toolbar . '
450
+ <div class="crayon-plain-wrap">' . $print_plain . '</div>' . '
451
+ <div class="crayon-main" style="' . $main_style . '">
452
  <table class="crayon-table">
453
  <tr class="crayon-row">';
454
 
455
+ if ($print_nums !== FALSE) {
456
+ $output .= '
457
+ <td class="crayon-nums ' . $num_vis . '" data-settings="' . $num_settings . '">
458
+ <div class="crayon-nums-content" style="' . $font_style . '">' . $print_nums . '</div>
459
  </td>';
460
+ }
461
+ // XXX
462
+ $output .= '
463
+ <td class="crayon-code"><div class="crayon-pre" style="' . $font_style . ' ' . $pre_style . '">' . $print_code . '</div></td>
464
  </tr>
465
  </table>
466
  </div>
467
  </div>';
468
+ // Debugging stats
469
+ $runtime = $hl->runtime();
470
+ if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
471
+ $output = '<!-- Crayon Syntax Highlighter v' . $CRAYON_VERSION . ' -->'
472
+ . CRAYON_NL . $output . CRAYON_NL . '<!-- ';
473
+ foreach ($hl->runtime() as $type => $time) {
474
+ $output .= '[' . $type . ': ' . sprintf('%.4f seconds', $time) . '] ';
475
+ }
476
+ $output .= '-->' . CRAYON_NL;
477
+ }
478
+ // Determine whether to print to screen or save
479
+ if ($print) {
480
+ echo $output;
481
+ } else {
482
+ return $output;
483
+ }
484
+ }
485
+
486
+ public static function print_error($hl, $error, $line_numbers = 'ERROR', $print = TRUE) {
487
+ if (get_class($hl) != CRAYON_HIGHLIGHTER) {
488
+ return;
489
+ }
490
+ // Either print the error returned by the handler, or a custom error message
491
+ if ($hl->setting_val(CrayonSettings::ERROR_MSG_SHOW)) {
492
+ $error = $hl->setting_val(CrayonSettings::ERROR_MSG);
493
+ }
494
+ $error = self::split_lines(trim($error), 'crayon-error');
495
+ return self::print_code($hl, $error, $line_numbers, $print);
496
+ }
497
+
498
+ // Delimiters =============================================================
499
+
500
+ public static function format_mixed_code($code, $language, $hl) {
501
+ self::$curr = $hl;
502
+ self::$delim_pieces = array();
503
+ // Remove crayon internal element from INPUT code
504
+ $code = preg_replace('#' . CrayonParser::CRAYON_ELEMENT_REGEX_CAPTURE . '#msi', '', $code);
505
+
506
+ if (self::$delimiters == NULL) {
507
+ self::$delimiters = CrayonResources::langs()->delimiters();
508
+ }
509
+
510
+ // Find all delimiters in all languages
511
+ if (self::$delim_regex == NULL) {
512
+ self::$delim_regex = '#(' . implode(')|(', array_values(self::$delimiters)) . ')#msi';
513
+ }
514
+
515
+ // Extract delimited code, replace with internal elements
516
+ $internal_code = preg_replace_callback(self::$delim_regex, 'CrayonFormatter::delim_to_internal', $code);
517
+
518
+ // Format with given language
519
+ $formatted_code = CrayonFormatter::format_code($internal_code, $language, $hl);
520
+
521
+ // Replace internal elements with delimited pieces
522
+ $formatted_code = preg_replace_callback('#\{\{crayon-internal:(\d+)\}\}#', 'CrayonFormatter::internal_to_code', $formatted_code);
523
+
524
+ return $formatted_code;
525
+ }
526
+
527
+ public static function delim_to_internal($matches) {
528
+ // Mark as mixed so we can show (+)
529
+ self::$curr->is_mixed(TRUE);
530
+ $capture_group = count($matches) - 2;
531
+ $capture_groups = array_keys(self::$delimiters);
532
+ $lang_id = $capture_groups[$capture_group];
533
+ if (($lang = CrayonResources::langs()->get($lang_id)) === NULL) {
534
+ return $matches[0];
535
+ }
536
+ $internal = sprintf('{{crayon-internal:%d}}', count(self::$delim_pieces));
537
+ // TODO fix
538
+ self::$delim_pieces[] = CrayonFormatter::format_code($matches[0], $lang, self::$curr);
539
+ return $internal;
540
+ }
541
+
542
+ public static function internal_to_code($matches) {
543
+ return self::$delim_pieces[intval($matches[1])];
544
+ }
545
+
546
+ // Auxiliary Methods ======================================================
547
+ /* Prepares code for formatting. */
548
+ public static function clean_code($code, $escape = TRUE, $spaces = FALSE, $tabs = FALSE, $lines = FALSE) {
549
+ if (empty($code)) {
550
+ return $code;
551
+ }
552
+ /* Convert <, > and & characters to entities, as these can appear as HTML tags and entities. */
553
+ if ($escape) {
554
+ $code = CrayonUtil::htmlspecialchars($code);
555
+ }
556
+ if ($spaces) {
557
+ // Replace 2 spaces with html escaped characters
558
+ $code = preg_replace('#[ ]{2}#msi', '&nbsp;&nbsp;', $code);
559
+ }
560
+ if ($tabs && CrayonGlobalSettings::val(CrayonSettings::TAB_CONVERT)) {
561
+ // Replace tabs with 4 spaces
562
+ $code = preg_replace('#\t#', str_repeat('&nbsp;', CrayonGlobalSettings::val(CrayonSettings::TAB_SIZE)), $code);
563
+ }
564
+ if ($lines) {
565
+ $code = preg_replace('#(\r\n)|\r|\n#msi', "\r\n", $code);
566
+ }
567
+ return $code;
568
+ }
569
+
570
+ /* Converts the code to entities and wraps in a <pre><code></code></pre> */
571
+ public static function plain_code($code, $encoded = TRUE) {
572
+ if (is_array($code)) {
573
+ // When used as a preg_replace_callback
574
+ $code = $code[1];
575
+ }
576
+ if (!$encoded) {
577
+ $code = CrayonUtil::htmlentities($code);
578
+ }
579
+ if (CrayonGlobalSettings::val(CrayonSettings::TRIM_WHITESPACE)) {
580
+ $code = trim($code);
581
+ }
582
+ return '<pre class="crayon-plain-tag">' . $code . '</pre>';
583
+ }
584
+
585
+ public static function split_lines($code, $class) {
586
+ $code = self::clean_code($code, TRUE, TRUE, TRUE, FALSE);
587
  $class = preg_replace('#(\w+)#m', 'crayon-$1', $class);
588
+ $code = preg_replace('#^([^\r\n]+)(?=\r\n|\r|\n|$)#m', '<span class="' . $class . '">$1</span>', $code);
589
+ return $code;
590
+ }
591
+
592
+ private static function dimension_style($hl, $name) {
593
+ $mode = $unit = '';
594
+ switch ($name) {
595
+ case CrayonSettings::HEIGHT :
596
+ $mode = CrayonSettings::HEIGHT_MODE;
597
+ $unit = CrayonSettings::HEIGHT_UNIT;
598
+ break;
599
+ case CrayonSettings::WIDTH :
600
+ $mode = CrayonSettings::WIDTH_MODE;
601
+ $unit = CrayonSettings::WIDTH_UNIT;
602
+ break;
603
+ }
604
+ // XXX Uses actual index value to identify options
605
+ $mode = $hl->setting_index($mode);
606
+ $unit = $hl->setting_index($unit);
607
+ $dim_mode = $dim_unit = '';
608
+ if ($mode !== FALSE) {
609
+ switch ($mode) {
610
+ case 0 :
611
+ $dim_mode .= 'max-';
612
+ break;
613
+ case 1 :
614
+ $dim_mode .= 'min-';
615
+ break;
616
+ }
617
+ }
618
+ $dim_mode .= $name;
619
+ if ($unit !== FALSE) {
620
+ switch ($unit) {
621
+ case 0 :
622
+ $dim_unit = 'px';
623
+ break;
624
+ case 1 :
625
+ $dim_unit = '%';
626
+ break;
627
+ }
628
+ }
629
+ return ' ' . $dim_mode . ': ' . $hl->setting_val($name) . $dim_unit . ';';
630
+ }
631
  }
632
+
633
  ?>
crayon_highlighter.class.php CHANGED
@@ -56,88 +56,65 @@ class CrayonHighlighter {
56
  $this->error('The specified URL is empty, please provide a valid URL.');
57
  return;
58
  }
59
- /* Try to replace the URL with an absolute path if it is local, used to prevent scripts
60
- from executing when they are loaded. */
61
  $url = $this->url;
62
  if ($this->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
63
  $url = CrayonUtil::html_entity_decode($url);
64
  }
65
  $url = CrayonUtil::pathf($url);
66
- $local = FALSE; // Whether to read locally
67
  $site_http = CrayonGlobalSettings::site_url();
68
- $site_path = CrayonGlobalSettings::site_path();
69
  $scheme = parse_url($url, PHP_URL_SCHEME);
70
-
71
  // Try to replace the site URL with a path to force local loading
72
- if (strpos($url, $site_http) !== FALSE || strpos($url, $site_path) !== FALSE ) {
73
- $url = str_replace($site_http, $site_path, $url);
74
- // Attempt to load locally
75
- $local = TRUE;
76
- $local_url = $url;
77
- } else if (empty($scheme)) {
78
  // No url scheme is given - path may be given as relative
79
- $local_url = preg_replace('#^((\/|\\\\)*)?#', $site_path . $this->setting_val(CrayonSettings::LOCAL_PATH), $url);
80
- $local = TRUE;
81
- }
82
- // Try to find the file locally
83
- if ($local == TRUE) {
84
- if ( ($contents = CrayonUtil::file($local_url)) !== FALSE ) {
85
- $this->code($contents);
 
 
 
 
86
  } else {
87
- $local = FALSE;
88
- CrayonLog::log("Local url ($local_url) could not be loaded", '', FALSE);
89
- }
90
- }
91
- // If reading the url locally produced an error or failed, attempt remote request
92
- if ($local == FALSE) {
93
- if (empty($scheme)) {
94
- $url = (CrayonUtil::isSecure() ? 'https://' : 'http://') . $url;
95
- }
96
- $http_code = 0;
97
- // If available, use the built in wp remote http get function, we don't need SSL
98
- if (function_exists('wp_remote_get')) {
99
- $url_uid = 'crayon_' . CrayonUtil::str_uid($url);
100
- $cached = get_transient($url_uid, 'crayon-syntax');
101
- CrayonSettingsWP::load_cache();
102
- if ($cached !== FALSE) {
103
- $content = $cached;
104
- $http_code = 200;
105
- } else {
106
- $response = @wp_remote_get($url, array('sslverify' => false, 'timeout' => 20));
107
- $content = wp_remote_retrieve_body($response);
108
- $http_code = wp_remote_retrieve_response_code($response);
109
- $cache = $this->setting_val(CrayonSettings::CACHE);
110
- $cache_sec = CrayonSettings::get_cache_sec($cache);
111
- if ($cache_sec > 1 && $http_code >= 200 && $http_code < 400) {
112
- set_transient($url_uid, $content, $cache_sec);
113
- CrayonSettingsWP::add_cache($url_uid);
114
- }
115
  }
116
- } else {
117
- $ch = curl_init($url);
118
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
119
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
120
- // For https connections, we do not require SSL verification
121
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
122
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
123
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
124
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, FALSE);
125
- curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
126
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
127
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
128
- }
129
- $content = curl_exec($ch);
130
- $error = curl_error($ch);
131
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
132
- curl_close($ch);
133
  }
134
- if ($http_code >= 200 && $http_code < 400) {
135
- $this->code($content);
136
- } else {
137
- if (empty($this->code)) {
138
- // If code is also given, just use that
139
- $this->error("The provided URL ('$this->url'), parsed remotely as ('$url'), could not be accessed.");
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
  }
143
  $this->needs_load = FALSE;
56
  $this->error('The specified URL is empty, please provide a valid URL.');
57
  return;
58
  }
59
+ // Try to replace the URL with an absolute path if it is local, used to prevent scripts
60
+ // from executing when they are loaded.
61
  $url = $this->url;
62
  if ($this->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
63
  $url = CrayonUtil::html_entity_decode($url);
64
  }
65
  $url = CrayonUtil::pathf($url);
 
66
  $site_http = CrayonGlobalSettings::site_url();
 
67
  $scheme = parse_url($url, PHP_URL_SCHEME);
 
68
  // Try to replace the site URL with a path to force local loading
69
+ if (empty($scheme)) {
 
 
 
 
 
70
  // No url scheme is given - path may be given as relative
71
+ $url = CrayonUtil::path_slash($site_http) . CrayonUtil::path_slash($this->setting_val(CrayonSettings::LOCAL_PATH)) . $url;
72
+ }
73
+ $http_code = 0;
74
+ // If available, use the built in wp remote http get function.
75
+ if (function_exists('wp_remote_get')) {
76
+ $url_uid = 'crayon_' . CrayonUtil::str_uid($url);
77
+ $cached = get_transient($url_uid, 'crayon-syntax');
78
+ CrayonSettingsWP::load_cache();
79
+ if ($cached !== FALSE) {
80
+ $content = $cached;
81
+ $http_code = 200;
82
  } else {
83
+ $response = @wp_remote_get($url, array('sslverify' => false, 'timeout' => 20));
84
+ $content = wp_remote_retrieve_body($response);
85
+ $http_code = wp_remote_retrieve_response_code($response);
86
+ $cache = $this->setting_val(CrayonSettings::CACHE);
87
+ $cache_sec = CrayonSettings::get_cache_sec($cache);
88
+ if ($cache_sec > 1 && $http_code >= 200 && $http_code < 400) {
89
+ set_transient($url_uid, $content, $cache_sec);
90
+ CrayonSettingsWP::add_cache($url_uid);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
+ } else if (in_array(parse_url($url, PHP_URL_SCHEME), array('ssl', 'http', 'https'))) {
94
+ // Fallback to cURL. At this point, the URL scheme must be valid.
95
+ $ch = curl_init($url);
96
+ curl_setopt($ch, CURLOPT_HEADER, FALSE);
97
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
98
+ // For https connections, we do not require SSL verification
99
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
100
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
101
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
102
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, FALSE);
103
+ curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
104
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
105
+ curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
106
+ }
107
+ $content = curl_exec($ch);
108
+ $error = curl_error($ch);
109
+ $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
110
+ curl_close($ch);
111
+ }
112
+ if ($http_code >= 200 && $http_code < 400) {
113
+ $this->code($content);
114
+ } else {
115
+ if (empty($this->code)) {
116
+ // If code is also given, just use that
117
+ $this->error("The provided URL ('$this->url'), parsed remotely as ('$url'), could not be accessed.");
118
  }
119
  }
120
  $this->needs_load = FALSE;
crayon_settings_wp.class.php CHANGED
@@ -644,10 +644,10 @@ class CrayonSettingsWP {
644
  $type = 'text';
645
  extract($args);
646
 
647
- echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" class="' . CrayonSettings::SETTING . '" size="', $size, '" type="', $type,'" value="',
648
  self::$options[$id], '" style="margin-left: ', ($margin ? '20px' : '0px'), ';" crayon-preview="', ($preview ? 1 : 0), '" />', ($break ? CRAYON_BR : '');
649
  }
650
-
651
  private static function checkbox($args, $line_break = TRUE, $preview = TRUE) {
652
  if (empty($args) || !is_array($args) || count($args) != 2) {
653
  return;
@@ -824,7 +824,7 @@ class CrayonSettingsWP {
824
  if (($langs = CrayonParser::parse_all()) != FALSE) {
825
  $langs = CrayonLangs::sort_by_name($langs);
826
  echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
827
- '<td>',crayon__('ID'),'</td><td>',crayon__('Name'),'</td><td>',crayon__('Version'),'</td><td>',crayon__('File Extensions'),'</td><td>',crayon__('Aliases'),'</td><td>',crayon__('State'),'</td></tr>';
828
  $keys = array_values($langs);
829
  for ($i = 0; $i < count($langs); $i++) {
830
  $lang = $keys[$i];
644
  $type = 'text';
645
  extract($args);
646
 
647
+ echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" class="' . CrayonSettings::SETTING . '" size="', $size, '" type="', $type, '" value="',
648
  self::$options[$id], '" style="margin-left: ', ($margin ? '20px' : '0px'), ';" crayon-preview="', ($preview ? 1 : 0), '" />', ($break ? CRAYON_BR : '');
649
  }
650
+
651
  private static function checkbox($args, $line_break = TRUE, $preview = TRUE) {
652
  if (empty($args) || !is_array($args) || count($args) != 2) {
653
  return;
824
  if (($langs = CrayonParser::parse_all()) != FALSE) {
825
  $langs = CrayonLangs::sort_by_name($langs);
826
  echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
827
+ '<td>', crayon__('ID'), '</td><td>', crayon__('Name'), '</td><td>', crayon__('Version'), '</td><td>', crayon__('File Extensions'), '</td><td>', crayon__('Aliases'), '</td><td>', crayon__('State'), '</td></tr>';
828
  $keys = array_values($langs);
829
  for ($i = 0; $i < count($langs); $i++) {
830
  $lang = $keys[$i];
crayon_wp.class.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: https://github.com/aramk/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
- Version: 2.6.10
7
  Author: Aram Kocharyan
8
  Author URI: http://aramk.com/
9
  Text Domain: crayon-syntax-highlighter
@@ -801,7 +801,7 @@ class CrayonWP {
801
  $post_class = preg_replace('#\bdata-url\s*=#mi', 'url=', $post_class);
802
  }
803
  if (!empty($pre_class)) {
804
- $pre_class = preg_replace('#\bdata-url\s*=#mi', 'url=', $post_class);
805
  }
806
 
807
  if (!empty($class)) {
@@ -979,7 +979,7 @@ class CrayonWP {
979
  add_action('wp_ajax_nopriv_crayon-tag-editor', 'CrayonTagEditorWP::content');
980
  add_action('wp_ajax_crayon-highlight', 'CrayonWP::ajax_highlight');
981
  add_action('wp_ajax_nopriv_crayon-highlight', 'CrayonWP::ajax_highlight');
982
- if (is_admin()) {
983
  add_action('wp_ajax_crayon-ajax', 'CrayonWP::ajax');
984
  add_action('wp_ajax_crayon-theme-editor', 'CrayonThemeEditorWP::content');
985
  add_action('wp_ajax_crayon-theme-editor-save', 'CrayonThemeEditorWP::save');
3
  Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: https://github.com/aramk/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
+ Version: 2.7.0
7
  Author: Aram Kocharyan
8
  Author URI: http://aramk.com/
9
  Text Domain: crayon-syntax-highlighter
801
  $post_class = preg_replace('#\bdata-url\s*=#mi', 'url=', $post_class);
802
  }
803
  if (!empty($pre_class)) {
804
+ $pre_class = preg_replace('#\bdata-url\s*=#mi', 'url=', $pre_class);
805
  }
806
 
807
  if (!empty($class)) {
979
  add_action('wp_ajax_nopriv_crayon-tag-editor', 'CrayonTagEditorWP::content');
980
  add_action('wp_ajax_crayon-highlight', 'CrayonWP::ajax_highlight');
981
  add_action('wp_ajax_nopriv_crayon-highlight', 'CrayonWP::ajax_highlight');
982
+ if (current_user_can('manage_options')) {
983
  add_action('wp_ajax_crayon-ajax', 'CrayonWP::ajax');
984
  add_action('wp_ajax_crayon-theme-editor', 'CrayonThemeEditorWP::content');
985
  add_action('wp_ajax_crayon-theme-editor-save', 'CrayonThemeEditorWP::save');
langs/ada/README.md CHANGED
@@ -13,4 +13,4 @@ Installation:
13
 
14
 
15
  Aram (crayons creator) has added it to the crayon repo here on github. So you can simply pull the current repo to get it.
16
- https://github.com/aramk/crayon-syntax-highlighter
13
 
14
 
15
  Aram (crayons creator) has added it to the crayon repo here on github. So you can simply pull the current repo to get it.
16
+ https://github.com/aramkocharyan/crayon-syntax-highlighter
langs/clojure/clojure.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### CLOJURE LANGUAGE ###
2
+
3
+ # ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
4
+
5
+ NAME Clojure
6
+ VERSION 1.0
7
+
8
+ COMMENT (;.*?$)|(;\|.*?\|;)
9
+ STRING (?<!\\)".*?(?<!\\)"
10
+
11
+ STATEMENT \b(?alt:statement.txt)\b
12
+ SPECIAL \b(?alt:special.txt)\b
13
+ TYPE \b(?alt:type.txt)\b
14
+ HOF \b(?alt:hof.txt)\b
15
+ VAR \b(?alt:vars.txt)\b
16
+ KEYWORD (?<=\()\s*[a-z-]*[a-z]\b
17
+
18
+ IDENTIFIER [a-z-]*[a-z]
19
+ CONSTANT (?default)
20
+ OPERATOR (?default)|\(|\)
21
+ SYMBOL (?default)
langs/clojure/hof.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ not-every?
2
+ not-any?
3
+ filter
4
+ reduce
5
+ every?
6
+ some
7
+ map
8
+ for
langs/clojure/special.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defrecord
2
+ defmacro
3
+ quote
4
+ throw
5
+ recur
6
+ defn
7
+ when
8
+ cond
9
+ loop
10
+ try
11
+ def
12
+ not
13
+ and
14
+ let
15
+ if
16
+ or
17
+ do
18
+ fn
langs/clojure/statement.txt ADDED
@@ -0,0 +1,577 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *
2
+ +
3
+ +'
4
+ -
5
+ -'
6
+ ->
7
+ ->&gt;
8
+ ->ArrayChunk
9
+ ->Vec
10
+ ->VecNode
11
+ ->VecSeq
12
+ -cache-protocol-fn
13
+ -reset-methods
14
+ .
15
+ ..
16
+ /
17
+ <
18
+ <=
19
+ =
20
+ ==
21
+ >
22
+ >=
23
+ accessor
24
+ aclone
25
+ add-classpath
26
+ add-watch
27
+ agent
28
+ agent-error
29
+ agent-errors
30
+ aget
31
+ alength
32
+ alias
33
+ all-ns
34
+ alter
35
+ alter-meta!
36
+ alter-var-root
37
+ amap
38
+ ancestors
39
+ and
40
+ apply
41
+ areduce
42
+ array-map
43
+ as-&gt;
44
+ aset
45
+ aset-boolean
46
+ aset-byte
47
+ aset-char
48
+ aset-double
49
+ aset-float
50
+ aset-int
51
+ aset-long
52
+ aset-short
53
+ assert
54
+ assoc
55
+ assoc!
56
+ assoc-in
57
+ associative?
58
+ atom
59
+ await
60
+ await-for
61
+ await1
62
+ bases
63
+ bean
64
+ bigdec
65
+ bigint
66
+ biginteger
67
+ binding
68
+ bit-and
69
+ bit-and-not
70
+ bit-clear
71
+ bit-flip
72
+ bit-not
73
+ bit-or
74
+ bit-set
75
+ bit-shift-left
76
+ bit-shift-right
77
+ bit-test
78
+ bit-xor
79
+ boolean
80
+ boolean-array
81
+ booleans
82
+ bound-fn
83
+ bound-fn*
84
+ bound?
85
+ butlast
86
+ byte
87
+ byte-array
88
+ bytes
89
+ case
90
+ cast
91
+ catch
92
+ char
93
+ char-array
94
+ char-escape-string
95
+ char-name-string
96
+ char?
97
+ chars
98
+ chunk
99
+ chunk-append
100
+ chunk-buffer
101
+ chunk-cons
102
+ chunk-first
103
+ chunk-next
104
+ chunk-rest
105
+ chunked-seq?
106
+ class
107
+ class?
108
+ clear-agent-errors
109
+ clojure-version
110
+ coll?
111
+ comment
112
+ commute
113
+ comp
114
+ comparator
115
+ compare
116
+ compare-and-set!
117
+ compile
118
+ complement
119
+ concat
120
+ cond
121
+ cond-&gt;
122
+ cond-&gt;&gt;
123
+ condp
124
+ conj
125
+ conj!
126
+ cons
127
+ constantly
128
+ construct-proxy
129
+ contains?
130
+ count
131
+ counted?
132
+ create-ns
133
+ create-struct
134
+ cycle
135
+ dec
136
+ dec'
137
+ decimal?
138
+ declare
139
+ def
140
+ default-data-readers
141
+ definline
142
+ definterface
143
+ defmacro
144
+ defmethod
145
+ defmulti
146
+ defn
147
+ defn-
148
+ defonce
149
+ defprotocol
150
+ defrecord
151
+ defstruct
152
+ deftype
153
+ delay
154
+ delay?
155
+ deliver
156
+ denominator
157
+ deref
158
+ derive
159
+ descendants
160
+ destructure
161
+ disj
162
+ disj!
163
+ dissoc
164
+ dissoc!
165
+ distinct
166
+ distinct?
167
+ do
168
+ doall
169
+ dorun
170
+ doseq
171
+ dosync
172
+ dotimes
173
+ doto
174
+ double
175
+ double-array
176
+ doubles
177
+ drop
178
+ drop-last
179
+ drop-while
180
+ empty
181
+ EMPTY-NODE
182
+ empty?
183
+ ensure
184
+ enumeration-seq
185
+ error-handler
186
+ error-mode
187
+ eval
188
+ even?
189
+ every-pred
190
+ every?
191
+ ex-data
192
+ ex-info
193
+ extend
194
+ extend-protocol
195
+ extend-type
196
+ extenders
197
+ extends?
198
+ false?
199
+ ffirst
200
+ file-seq
201
+ filter
202
+ filterv
203
+ finally
204
+ find
205
+ find-keyword
206
+ find-ns
207
+ find-protocol-impl
208
+ find-protocol-method
209
+ find-var
210
+ first
211
+ flatten
212
+ float
213
+ float-array
214
+ float?
215
+ floats
216
+ flush
217
+ fn
218
+ fn?
219
+ fnext
220
+ fnil
221
+ for
222
+ force
223
+ format
224
+ frequencies
225
+ future
226
+ future-call
227
+ future-cancel
228
+ future-cancelled?
229
+ future-done?
230
+ future?
231
+ gen-class
232
+ gen-interface
233
+ gensym
234
+ get
235
+ get-in
236
+ get-method
237
+ get-proxy-class
238
+ get-thread-bindings
239
+ get-validator
240
+ group-by
241
+ hash
242
+ hash-combine
243
+ hash-map
244
+ hash-ordered-coll
245
+ hash-set
246
+ hash-unordered-coll
247
+ identical?
248
+ identity
249
+ if
250
+ if-let
251
+ if-not
252
+ if-some
253
+ ifn?
254
+ import
255
+ in-ns
256
+ inc
257
+ inc'
258
+ init-proxy
259
+ instance?
260
+ int
261
+ int-array
262
+ integer?
263
+ interleave
264
+ intern
265
+ interpose
266
+ into
267
+ into-array
268
+ ints
269
+ io!
270
+ isa?
271
+ iterate
272
+ iterator-seq
273
+ juxt
274
+ keep
275
+ keep-indexed
276
+ key
277
+ keys
278
+ keyword
279
+ keyword?
280
+ last
281
+ lazy-cat
282
+ lazy-seq
283
+ let
284
+ letfn
285
+ line-seq
286
+ list
287
+ list*
288
+ list?
289
+ load
290
+ load-file
291
+ load-reader
292
+ load-string
293
+ loaded-libs
294
+ locking
295
+ long
296
+ long-array
297
+ longs
298
+ loop
299
+ macroexpand
300
+ macroexpand-1
301
+ make-array
302
+ make-hierarchy
303
+ map
304
+ map-indexed
305
+ map?
306
+ mapcat
307
+ mapv
308
+ max
309
+ max-key
310
+ memfn
311
+ memoize
312
+ merge
313
+ merge-with
314
+ meta
315
+ method-sig
316
+ methods
317
+ min
318
+ min-key
319
+ mix-collection-hash
320
+ mod
321
+ munge
322
+ name
323
+ namespace
324
+ namespace-munge
325
+ neg?
326
+ newline
327
+ next
328
+ nfirst
329
+ nil?
330
+ nnext
331
+ not
332
+ not-any?
333
+ not-empty
334
+ not-every?
335
+ not=
336
+ ns
337
+ ns-aliases
338
+ ns-imports
339
+ ns-interns
340
+ ns-map
341
+ ns-name
342
+ ns-publics
343
+ ns-refers
344
+ ns-resolve
345
+ ns-unalias
346
+ ns-unmap
347
+ nth
348
+ nthnext
349
+ nthrest
350
+ num
351
+ number?
352
+ numerator
353
+ object-array
354
+ odd?
355
+ or
356
+ parents
357
+ partial
358
+ partition
359
+ partition-all
360
+ partition-by
361
+ pcalls
362
+ peek
363
+ persistent!
364
+ pmap
365
+ pop
366
+ pop!
367
+ pop-thread-bindings
368
+ pos?
369
+ pr
370
+ pr-str
371
+ prefer-method
372
+ prefers
373
+ primitives-classnames
374
+ print
375
+ print-ctor
376
+ print-dup
377
+ print-method
378
+ print-simple
379
+ print-str
380
+ printf
381
+ println
382
+ println-str
383
+ prn
384
+ prn-str
385
+ promise
386
+ proxy
387
+ proxy-call-with-super
388
+ proxy-mappings
389
+ proxy-name
390
+ proxy-super
391
+ push-thread-bindings
392
+ pvalues
393
+ quot
394
+ quote
395
+ rand
396
+ rand-int
397
+ rand-nth
398
+ range
399
+ ratio?
400
+ rational?
401
+ rationalize
402
+ re-find
403
+ re-groups
404
+ re-matcher
405
+ re-matches
406
+ re-pattern
407
+ re-seq
408
+ read
409
+ read-line
410
+ read-string
411
+ realized?
412
+ record?
413
+ recur
414
+ reduce
415
+ reduce-kv
416
+ reduced
417
+ reduced?
418
+ reductions
419
+ ref
420
+ ref-history-count
421
+ ref-max-history
422
+ ref-min-history
423
+ ref-set
424
+ refer
425
+ refer-clojure
426
+ reify
427
+ release-pending-sends
428
+ rem
429
+ remove
430
+ remove-all-methods
431
+ remove-method
432
+ remove-ns
433
+ remove-watch
434
+ repeat
435
+ repeatedly
436
+ replace
437
+ replicate
438
+ require
439
+ reset!
440
+ reset-meta!
441
+ resolve
442
+ rest
443
+ restart-agent
444
+ resultset-seq
445
+ reverse
446
+ reversible?
447
+ rseq
448
+ rsubseq
449
+ satisfies?
450
+ second
451
+ select-keys
452
+ send
453
+ send-off
454
+ send-via
455
+ seq
456
+ seq?
457
+ seque
458
+ sequence
459
+ sequential?
460
+ set
461
+ set!
462
+ set-agent-send-executor!
463
+ set-agent-send-off-executor!
464
+ set-error-handler!
465
+ set-error-mode!
466
+ set-validator!
467
+ set?
468
+ short
469
+ short-array
470
+ shorts
471
+ shuffle
472
+ shutdown-agents
473
+ slurp
474
+ some
475
+ some-&gt;
476
+ some-&gt;&gt;
477
+ some-fn
478
+ some?
479
+ sort
480
+ sort-by
481
+ sorted-map
482
+ sorted-map-by
483
+ sorted-set
484
+ sorted-set-by
485
+ sorted?
486
+ special-symbol?
487
+ spit
488
+ split-at
489
+ split-with
490
+ str
491
+ string?
492
+ struct
493
+ struct-map
494
+ subs
495
+ subseq
496
+ subvec
497
+ supers
498
+ swap!
499
+ symbol
500
+ symbol?
501
+ sync
502
+ take
503
+ take-last
504
+ take-nth
505
+ take-while
506
+ test
507
+ the-ns
508
+ thread-bound?
509
+ throw
510
+ time
511
+ to-array
512
+ to-array-2d
513
+ trampoline
514
+ transient
515
+ tree-seq
516
+ true?
517
+ try
518
+ type
519
+ unchecked-add
520
+ unchecked-add-int
521
+ unchecked-byte
522
+ unchecked-char
523
+ unchecked-dec
524
+ unchecked-dec-int
525
+ unchecked-divide-int
526
+ unchecked-double
527
+ unchecked-float
528
+ unchecked-inc
529
+ unchecked-inc-int
530
+ unchecked-int
531
+ unchecked-long
532
+ unchecked-multiply
533
+ unchecked-multiply-int
534
+ unchecked-negate
535
+ unchecked-negate-int
536
+ unchecked-remainder-int
537
+ unchecked-short
538
+ unchecked-subtract
539
+ unchecked-subtract-int
540
+ underive
541
+ unquote
542
+ unquote-splicing
543
+ unsigned-bit-shift-right
544
+ update-in
545
+ update-proxy
546
+ use
547
+ val
548
+ vals
549
+ var
550
+ var-get
551
+ var-set
552
+ var?
553
+ vary-meta
554
+ vec
555
+ vector
556
+ vector-of
557
+ vector?
558
+ when
559
+ when-first
560
+ when-let
561
+ when-not
562
+ when-some
563
+ while
564
+ with-bindings
565
+ with-bindings*
566
+ with-in-str
567
+ with-loading-context
568
+ with-local-vars
569
+ with-meta
570
+ with-open
571
+ with-out-str
572
+ with-precision
573
+ with-redefs
574
+ with-redefs-fn
575
+ xml-seq
576
+ zero?
577
+ zipmap
langs/clojure/type.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ vector
2
+ map-hash
3
+ list
4
+ atom
5
+ seq
langs/clojure/vars.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *'
2
+ *1
3
+ *2
4
+ *3
5
+ *agent*
6
+ *allow-unresolved-vars*
7
+ *assert*
8
+ *clojure-version*
9
+ *command-line-args*
10
+ *compile-files*
11
+ *compile-path*
12
+ *compiler-options*
13
+ *data-readers*
14
+ *default-data-reader-fn*
15
+ *e
16
+ *err*
17
+ *file*
18
+ *flush-on-newline*
19
+ *fn-loader*
20
+ *in*
21
+ *math-context*
22
+ *ns*
23
+ *out*
24
+ *print-dup*
25
+ *print-length*
26
+ *print-level*
27
+ *print-meta*
28
+ *print-readably*
29
+ *read-eval*
30
+ *source-path*
31
+ *unchecked-math*
32
+ *use-context-classloader*
33
+ *verbose-defrecords*
34
+ *warn-on-reflection*
readme.txt CHANGED
@@ -7,12 +7,12 @@ Requires at least: 3.0
7
  Tested up to: 4.1.0
8
  Stable tag: trunk
9
 
10
- Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
11
 
12
  == Description ==
13
 
14
  A Syntax Highlighter built in PHP and jQuery that supports customizable languages and themes.
15
- It can highlight from a URL, a local file or Wordpress post text. Crayon makes it easy to manage Language files and define
16
  custom language elements with regular expressions.
17
  It also supports some neat features like:
18
 
@@ -46,7 +46,6 @@ It also supports some neat features like:
46
  * Line marking (for important lines)
47
  * <a href="http://aramk.com/blog/2012/09/02/line-ranges-in-crayon‎" target="_blank">Line ranges (showing only parts of the code)</a>
48
  * Starting line number (default is 1)
49
- * Local directory to search for local files
50
  * File extension detection
51
  * Live Preview in settings
52
  * Dimensions, margins, alignment, font-size, line-height, float
@@ -85,6 +84,7 @@ See the <a href="http://aramk.com/blog/2011/09/23/crayon-language-file-specifica
85
  * C
86
  * C#
87
  * C++
 
88
  * CoffeeScript (thanks to <a href="http://firn.jp/crayon-coffeescript" target="_blank">Dai Akatsuka</a>)
89
  * CSS
90
  * Delphi/Pascal (thanks to <a href="http://squashbrain.com/" target="_blank">Chris McClenny</a>)
@@ -198,6 +198,7 @@ A handful of articles from others written about Crayon, thanks guys!
198
 
199
  Thanks to all those who donate to the project:
200
 
 
201
  * ZengChun Yang, China
202
  * Alan Kaplan, (http://www.akaplan.com/blog), US
203
  * Christopher Yarbrough, (http://chrisyarbrough.com/), Germany
@@ -297,6 +298,15 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
297
 
298
  == Changelog ==
299
 
 
 
 
 
 
 
 
 
 
300
  = 2.6.10 =
301
  * ADDED:
302
  * Option to load crayon script in the footer to improve loading performance (thanks to <a href="https://github.com/sumhat" target="_blank">sumhat</a>).
7
  Tested up to: 4.1.0
8
  Stable tag: trunk
9
 
10
+ Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, or post text.
11
 
12
  == Description ==
13
 
14
  A Syntax Highlighter built in PHP and jQuery that supports customizable languages and themes.
15
+ It can highlight from a URL, or Wordpress post text. Crayon makes it easy to manage Language files and define
16
  custom language elements with regular expressions.
17
  It also supports some neat features like:
18
 
46
  * Line marking (for important lines)
47
  * <a href="http://aramk.com/blog/2012/09/02/line-ranges-in-crayon‎" target="_blank">Line ranges (showing only parts of the code)</a>
48
  * Starting line number (default is 1)
 
49
  * File extension detection
50
  * Live Preview in settings
51
  * Dimensions, margins, alignment, font-size, line-height, float
84
  * C
85
  * C#
86
  * C++
87
+ * Clojure (thanks to <a href="https://github.com/mberndtgen" target="_blank"></a>)
88
  * CoffeeScript (thanks to <a href="http://firn.jp/crayon-coffeescript" target="_blank">Dai Akatsuka</a>)
89
  * CSS
90
  * Delphi/Pascal (thanks to <a href="http://squashbrain.com/" target="_blank">Chris McClenny</a>)
198
 
199
  Thanks to all those who donate to the project:
200
 
201
+ * Nilesh Govindrajan, (http://nileshgr.com/), India
202
  * ZengChun Yang, China
203
  * Alan Kaplan, (http://www.akaplan.com/blog), US
204
  * Christopher Yarbrough, (http://chrisyarbrough.com/), Germany
298
 
299
  == Changelog ==
300
 
301
+ = 2.7.0 =
302
+ * ADDED:
303
+ * Onderka15 theme.
304
+ * Obsidian Light theme.
305
+ * FIXED:
306
+ * Prevented using is_admin() as a security query (thanks to <a href="https://research.g0blin.co.uk/" target="_blank">g0blin Research</a>).
307
+ * Removed the ability to load files from the filesystem due to security vulnerabilities (thanks to <a href="http://kevinsubileau.fr" target="_blank">Kevin Subileau</a>). Ensure all URLs are publicly accessible.
308
+ * Fixed a bug causing tags to be removed in some cases.
309
+
310
  = 2.6.10 =
311
  * ADDED:
312
  * Option to load crayon script in the footer to improve loading performance (thanks to <a href="https://github.com/sumhat" target="_blank">sumhat</a>).
themes/obsidian-light/obsidian-light.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Obsidian Light
3
+ Description: Eclipse Obsidian theme inspired by http://eclipsecolorthemes.org/?view=theme&id=21
4
+ Version: 1.0
5
+ Author: Wolfgang Magerl
6
+ URL: http://stonefred.at
7
+ */
8
+ .crayon-theme-obsidian-light {
9
+ color: #e0e2e4;
10
+ margin-bottom: 25px !important;
11
+ background-color: #f8f8ff !important;
12
+ font-size: 100% !important;
13
+ line-height: 130% !important;
14
+ background: #f5f5f5 !important;
15
+ border-style: solid !important;
16
+ border-width: 1px !important;
17
+ border-color: #dcdcdc !important;
18
+ }
19
+ .crayon-syntax .crayon-pre {
20
+ color: #e0e2e4;
21
+ }
22
+ .crayon-syntax pre {
23
+ color: #e0e2e4;
24
+ }
25
+ .crayon-theme-obsidian-light .crayon-toolbar {
26
+ background-color: #eee !important;
27
+ border-bottom-color: 1px solid #dedede !important;
28
+ }
29
+ .crayon-theme-obsidian-light .crayon-toolbar .crayon-language {
30
+ font-size: 80% !important;
31
+ color: #666 !important;
32
+ }
33
+ .crayon-theme-obsidian-light .crayon-toolbar .crayon-title {
34
+ font-size: 80% !important;
35
+ color: #666 !important;
36
+ }
37
+ .crayon-theme-obsidian-light .crayon-table .crayon-nums {
38
+ background-color: #eee !important;
39
+ background: #f5f5f5 !important;
40
+ color: #7f7f7f !important;
41
+ border-right-width: 1px !important;
42
+ border-right-color: #7f7f7f !important;
43
+ }
44
+ .crayon-theme-obsidian-light .crayon-table .crayon-nums-content {
45
+ padding-top: 5px !important;
46
+ padding-bottom: 3px !important;
47
+ }
48
+ .crayon-theme-obsidian-light .crayon-table .crayon-num {
49
+ min-width: 1.2em !important;
50
+ text-align: right !important;
51
+ color: #81969a !important;
52
+ border-right-style: solid !important;
53
+ border-right-width: 1px !important;
54
+ border-right-color: #81969a !important;
55
+ }
56
+ .crayon-theme-obsidian-light .crayon-pre {
57
+ padding-top: 5px !important;
58
+ padding-bottom: 3px !important;
59
+ color: #000000 !important;
60
+ }
61
+ .crayon-theme-obsidian-light .crayon-marked-line {
62
+ background: #dcdcdc !important;
63
+ border-width: 1px !important;
64
+ border-color: #7f7f7f !important;
65
+ }
66
+ .crayon-theme-obsidian-light .crayon-marked-num {
67
+ color: #7f7f7f !important;
68
+ background: #dcdcdc !important;
69
+ border-width: 1px !important;
70
+ border-color: #7f7f7f !important;
71
+ }
72
+ .crayon-theme-obsidian-light .crayon-pre .crayon-c {
73
+ color: #7f7f7f !important;
74
+ }
75
+ .crayon-theme-obsidian-light .crayon-pre .crayon-s {
76
+ color: #ff6400 !important;
77
+ }
78
+ .crayon-theme-obsidian-light .crayon-pre .crayon-p {
79
+ color: #af0f91 !important;
80
+ }
81
+ .crayon-theme-obsidian-light .crayon-pre .crayon-ta {
82
+ color: #000000 !important;
83
+ }
84
+ .crayon-theme-obsidian-light .crayon-pre .crayon-k {
85
+ color: #000000 !important;
86
+ }
87
+ .crayon-theme-obsidian-light .crayon-pre .crayon-st {
88
+ color: #000000 !important;
89
+ }
90
+ .crayon-theme-obsidian-light .crayon-pre .crayon-r {
91
+ color: #000000 !important;
92
+ }
93
+ .crayon-theme-obsidian-light .crayon-pre .crayon-t {
94
+ color: #1d881d !important;
95
+ }
96
+ .crayon-theme-obsidian-light .crayon-pre .crayon-m {
97
+ color: #1d881d !important;
98
+ }
99
+ .crayon-theme-obsidian-light .crayon-pre .crayon-i {
100
+ color: #000000 !important;
101
+ }
102
+ .crayon-theme-obsidian-light .crayon-pre .crayon-e {
103
+ color: #3f3fff !important;
104
+ }
105
+ .crayon-theme-obsidian-light .crayon-pre .crayon-v {
106
+ color: #000000 !important;
107
+ }
108
+ .crayon-theme-obsidian-light .crayon-pre .crayon-cn {
109
+ color: #af0f91 !important;
110
+ }
111
+ .crayon-theme-obsidian-light .crayon-pre .crayon-o {
112
+ color: #000000 !important;
113
+ }
114
+ .crayon-theme-obsidian-light .crayon-pre .crayon-sy {
115
+ color: #000000 !important;
116
+ }
117
+ .crayon-theme-obsidian-light .crayon-pre .crayon-n {
118
+ color: #666666 !important;
119
+ font-style: italic !important;
120
+ }
121
+ .crayon-theme-obsidian-light .crayon-pre .crayon-f {
122
+ color: #999999 !important;
123
+ }
124
+ .crayon-theme-obsidian-light .crayon-pre .crayon-h {
125
+ color: #000000 !important;
126
+ }
127
+ .crayon-theme-obsidian-light .crayon-marked-line.crayon-top {
128
+ border-top-style: solid !important;
129
+ }
130
+ .crayon-theme-obsidian-light .crayon-marked-line.crayon-bottom {
131
+ border-bottom-style: solid !important;
132
+ }
133
+ .crayon-theme-obsidian-light .crayon-marked-num.crayon-top {
134
+ border-top-style: solid !important;
135
+ }
136
+ .crayon-theme-obsidian-light .crayon-marked-num.crayon-bottom {
137
+ border-bottom-style: solid !important;
138
+ }
139
+ .crayon-theme-obsidian-light .crayon-striped-num {
140
+ color: #7f7f7f !important;
141
+ background: #f5f5f5 !important;
142
+ }
143
+ .crayon-theme-obsidian-light .crayon-marked-num.crayon-striped-num {
144
+ background: #dcdcdc !important;
145
+ color: #7f7f7f !important;
146
+ }
147
+ .crayon-theme-obsidian-light .crayon-striped-line {
148
+ background: #f5f5f5 !important;
149
+ }
150
+ .crayon-theme-obsidian-light .crayon-marked-line.crayon-striped-line {
151
+ background: #dcdcdc !important;
152
+ }
153
+ .crayon-theme-obsidian-light-inline {
154
+ background: #dcdcdc !important;
155
+ border-width: 1px !important;
156
+ border-color: #dcdcdc !important;
157
+ }
themes/onderka15/onderka15.css ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Onderka15
3
+ Description: Version: 1.0
4
+ Author: Stefan Onderka
5
+ URL: http://www.onderka.com
6
+ */
7
+ .crayon-theme-onderka15 {
8
+ border-width: 1px !important;
9
+ text-shadow: none !important;
10
+ background: #f8f8f8 !important;
11
+ border-color: #c8c8c8 !important;
12
+ border-style: solid !important;
13
+ }
14
+ .crayon-theme-onderka15-inline {
15
+ border-width: 1px !important;
16
+ border-color: #ddd !important;
17
+ background: #f8f8f8 !important;
18
+ border-style: solid !important;
19
+ }
20
+ .crayon-theme-onderka15 .crayon-table .crayon-nums {
21
+ background: #c0c0c0 !important;
22
+ color: #696969 !important;
23
+ }
24
+ .crayon-theme-onderka15 .crayon-striped-line {
25
+ background: #f8f8f8 !important;
26
+ }
27
+ .crayon-theme-onderka15 .crayon-striped-num {
28
+ background: #c0c0c0 !important;
29
+ color: #696969 !important;
30
+ }
31
+ .crayon-theme-onderka15 .crayon-marked-line {
32
+ border-width: 1px !important;
33
+ border-color: #c7c7c7 !important;
34
+ background: #ffffff !important;
35
+ }
36
+ .crayon-theme-onderka15 .crayon-marked-num {
37
+ color: #ffffff !important;
38
+ background: #c0c0c0 !important;
39
+ border-width: 1px !important;
40
+ border-color: #939393 !important;
41
+ }
42
+ .crayon-theme-onderka15 .crayon-marked-line.crayon-striped-line {
43
+ background: #f8f8f8 !important;
44
+ }
45
+ .crayon-theme-onderka15 .crayon-marked-num.crayon-striped-num {
46
+ background: #c0c0c0 !important;
47
+ color: #ffffff !important;
48
+ }
49
+ .crayon-theme-onderka15 .crayon-marked-line.crayon-top {
50
+ border-top-style: solid !important;
51
+ }
52
+ .crayon-theme-onderka15 .crayon-marked-num.crayon-top {
53
+ border-top-style: solid !important;
54
+ }
55
+ .crayon-theme-onderka15 .crayon-marked-line.crayon-bottom {
56
+ border-bottom-style: solid !important;
57
+ }
58
+ .crayon-theme-onderka15 .crayon-marked-num.crayon-bottom {
59
+ border-bottom-style: solid !important;
60
+ }
61
+ .crayon-theme-onderka15 .crayon-info {
62
+ background: #909090 !important;
63
+ border-bottom-width: 1px !important;
64
+ border-bottom-color: #696969 !important;
65
+ border-bottom-style: solid !important;
66
+ color: #c0c0c0 !important;
67
+ }
68
+ .crayon-theme-onderka15 .crayon-toolbar {
69
+ background: #eeeeee !important;
70
+ border-bottom-width: 1px !important;
71
+ border-bottom-color: #dddddd !important;
72
+ border-bottom-style: solid !important;
73
+ }
74
+ .crayon-theme-onderka15 .crayon-toolbar > div {
75
+ float: left !important;
76
+ }
77
+ .crayon-theme-onderka15 .crayon-toolbar .crayon-tools {
78
+ float: right !important;
79
+ }
80
+ .crayon-theme-onderka15 .crayon-title {
81
+ color: #999999 !important;
82
+ }
83
+ .crayon-theme-onderka15 .crayon-language {
84
+ color: #999 !important;
85
+ }
86
+ .crayon-theme-onderka15 a.crayon-button {
87
+ background-color: transparent !important;
88
+ }
89
+ .crayon-theme-onderka15 a.crayon-button:hover {
90
+ background-color: #dddddd !important;
91
+ color: #666;
92
+ }
93
+ .crayon-theme-onderka15 a.crayon-button.crayon-pressed:hover {
94
+ background-color: #eeeeee !important;
95
+ color: #666;
96
+ }
97
+ .crayon-theme-onderka15 a.crayon-button.crayon-pressed {
98
+ background-color: #dddddd !important;
99
+ color: #FFF;
100
+ }
101
+ .crayon-theme-onderka15 a.crayon-button.crayon-pressed:active {
102
+ background-color: #dddddd !important;
103
+ color: #FFF;
104
+ }
105
+ .crayon-theme-onderka15 a.crayon-button:active {
106
+ background-color: #dddddd !important;
107
+ color: #FFF;
108
+ }
109
+ .crayon-theme-onderka15 .crayon-pre .crayon-c {
110
+ color: #32cd32 !important;
111
+ }
112
+ .crayon-theme-onderka15 .crayon-pre .crayon-s {
113
+ color: #1996d4 !important;
114
+ }
115
+ .crayon-theme-onderka15 .crayon-pre .crayon-p {
116
+ color: #222222 !important;
117
+ }
118
+ .crayon-theme-onderka15 .crayon-pre .crayon-ta {
119
+ color: #e91e1e !important;
120
+ }
121
+ .crayon-theme-onderka15 .crayon-pre .crayon-k {
122
+ color: #006699 !important;
123
+ }
124
+ .crayon-theme-onderka15 .crayon-pre .crayon-st {
125
+ color: #cc6600 !important;
126
+ font-weight: bold !important;
127
+ }
128
+ .crayon-theme-onderka15 .crayon-pre .crayon-r {
129
+ color: #cc6600 !important;
130
+ }
131
+ .crayon-theme-onderka15 .crayon-pre .crayon-t {
132
+ color: #CC6600 !important;
133
+ }
134
+ .crayon-theme-onderka15 .crayon-pre .crayon-m {
135
+ color: #cc6600 !important;
136
+ }
137
+ .crayon-theme-onderka15 .crayon-pre .crayon-i {
138
+ color: #222222 !important;
139
+ }
140
+ .crayon-theme-onderka15 .crayon-pre .crayon-e {
141
+ color: #cc6600 !important;
142
+ }
143
+ .crayon-theme-onderka15 .crayon-pre .crayon-v {
144
+ color: #222222 !important;
145
+ }
146
+ .crayon-theme-onderka15 .crayon-pre .crayon-cn {
147
+ color: #222222 !important;
148
+ }
149
+ .crayon-theme-onderka15 .crayon-pre .crayon-o {
150
+ color: #222222 !important;
151
+ }
152
+ .crayon-theme-onderka15 .crayon-pre .crayon-sy {
153
+ color: #333 !important;
154
+ }
155
+ .crayon-theme-onderka15 .crayon-pre .crayon-n {
156
+ color: #666 !important;
157
+ font-style: italic !important;
158
+ }
159
+ .crayon-theme-onderka15 .crayon-pre .crayon-f {
160
+ color: #999 !important;
161
+ }
162
+ .crayon-theme-onderka15 .crayon-pre .crayon-h {
163
+ color: #006fe0 !important;
164
+ }
165
+ .crayon-theme-onderka15 .crayon-pre {
166
+ color: #959595 !important;
167
+ }
util/sample/clojure.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ (defn keyword-params-request
2
+ "Converts string keys in :params map to keywords. See: wrap-keyword-params."
3
+ {:added "1.2"}
4
+ [request]
5
+ (update-in request [:params] keyify-params))