Changeset 1787934
- Timestamp:
- 12/16/2017 09:29:13 AM (8 years ago)
- Location:
- fv-code-highlighter
- Files:
-
- 2 added
- 2 deleted
- 31 edited
- 16 copied
-
tags/2.0.2 (copied) (copied from fv-code-highlighter/trunk)
-
tags/2.0.2/cache (copied) (copied from fv-code-highlighter/trunk/cache)
-
tags/2.0.2/composer.json (copied) (copied from fv-code-highlighter/trunk/composer.json)
-
tags/2.0.2/fv-code-highlighter.php (copied) (copied from fv-code-highlighter/trunk/fv-code-highlighter.php) (1 diff)
-
tags/2.0.2/public (copied) (copied from fv-code-highlighter/trunk/public)
-
tags/2.0.2/public/css/fvch-styles.css (deleted)
-
tags/2.0.2/public/css/fvch-styles.min.css (copied) (copied from fv-code-highlighter/trunk/public/css/fvch-styles.min.css) (1 diff)
-
tags/2.0.2/public/css/fvch-styles.scss (added)
-
tags/2.0.2/readme.txt (copied) (copied from fv-code-highlighter/trunk/readme.txt) (3 diffs)
-
tags/2.0.2/screenshot-1.png (copied) (copied from fv-code-highlighter/trunk/screenshot-1.png)
-
tags/2.0.2/screenshot-2.png (copied) (copied from fv-code-highlighter/trunk/screenshot-2.png)
-
tags/2.0.2/screenshot-3.png (copied) (copied from fv-code-highlighter/trunk/screenshot-3.png)
-
tags/2.0.2/screenshot-4.png (copied) (copied from fv-code-highlighter/trunk/screenshot-4.png)
-
tags/2.0.2/screenshot-5.png (copied) (copied from fv-code-highlighter/trunk/screenshot-5.png)
-
tags/2.0.2/screenshot-6.png (copied) (copied from fv-code-highlighter/trunk/screenshot-6.png)
-
tags/2.0.2/screenshot-7.png (copied) (copied from fv-code-highlighter/trunk/screenshot-7.png)
-
tags/2.0.2/src (copied) (copied from fv-code-highlighter/trunk/src)
-
tags/2.0.2/src/Admin/Options.php (modified) (2 diffs)
-
tags/2.0.2/src/Application/Bootstrap.php (modified) (1 diff)
-
tags/2.0.2/src/Cache.php (modified) (3 diffs)
-
tags/2.0.2/src/Highlighter/AbstractHighlighter.php (modified) (2 diffs)
-
tags/2.0.2/src/Highlighter/Php/Factory.php (modified) (5 diffs)
-
tags/2.0.2/src/Highlighter/Php/Php.php (modified) (2 diffs)
-
tags/2.0.2/src/Installer.php (modified) (1 diff)
-
tags/2.0.2/src/Options.php (copied) (copied from fv-code-highlighter/trunk/src/Options.php) (1 diff)
-
tags/2.0.2/src/Output.php (modified) (4 diffs)
-
tags/2.0.2/src/Parser/Element/Block.php (modified) (2 diffs)
-
tags/2.0.2/src/Parser/Parser.php (modified) (4 diffs)
-
trunk/fv-code-highlighter.php (modified) (1 diff)
-
trunk/public/css/fvch-styles.css (deleted)
-
trunk/public/css/fvch-styles.min.css (modified) (1 diff)
-
trunk/public/css/fvch-styles.scss (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/screenshot-1.png (modified) (previous)
-
trunk/screenshot-2.png (modified) (previous)
-
trunk/screenshot-3.png (modified) (previous)
-
trunk/screenshot-4.png (modified) (previous)
-
trunk/screenshot-5.png (modified) (previous)
-
trunk/screenshot-6.png (modified) (previous)
-
trunk/screenshot-7.png (modified) (previous)
-
trunk/src/Admin/Options.php (modified) (2 diffs)
-
trunk/src/Application/Bootstrap.php (modified) (1 diff)
-
trunk/src/Cache.php (modified) (3 diffs)
-
trunk/src/Highlighter/AbstractHighlighter.php (modified) (2 diffs)
-
trunk/src/Highlighter/Php/Factory.php (modified) (5 diffs)
-
trunk/src/Highlighter/Php/Php.php (modified) (2 diffs)
-
trunk/src/Installer.php (modified) (1 diff)
-
trunk/src/Options.php (modified) (1 diff)
-
trunk/src/Output.php (modified) (4 diffs)
-
trunk/src/Parser/Element/Block.php (modified) (2 diffs)
-
trunk/src/Parser/Parser.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fv-code-highlighter/tags/2.0.2/fv-code-highlighter.php
r1773975 r1787934 7 7 * Author: Frank Verhoeven 8 8 * Author URI: https://frankverhoeven.me/ 9 * Version: 2.0. 19 * Version: 2.0.2 10 10 */ 11 11 12 12 final class FvCodeHighlighter 13 13 { 14 const VERSION = '2.0. 1';14 const VERSION = '2.0.2'; 15 15 16 16 /** -
fv-code-highlighter/tags/2.0.2/public/css/fvch-styles.min.css
r1773975 r1787934 1 .fvch-hide-if-no-js{display:none !important}.fvch-codeblock{background:url(../images/notepaper.png) top left repeat;border:1px solid #d2d2d2;padding:0 !important;margin:0 0 1em;border-radius:3px;overflow-x:auto;position:relative ;font-size:10px}.fvch-codeblock table,.fvch-codeblock thead,.fvch-codeblock tbody,.fvch-codeblock tr,.fvch-codeblock td,.fvch-codeblock pre{padding:0;margin:0;border:none}.fvch-codeblock pre{white-space:pre;padding-left:.5em;font-family:"Monaco", "Courier New", Courier, monospace;border:none !important;background:none !important;color:inherit !important}.fvch-toolbox{position:absolute;top:0;right:0;display:none;border-left:1px solid #d2d2d2;border-bottom:1px solid #d2d2d2;border-bottom-left-radius:3px;border-top-right-radius:3px;background:#fff;padding:3px 6px 0}.fvch-codeblock:hover .fvch-toolbox{display:block}.fvch-toolbox .fvch-toolbox-icon{border:none !important;background:none !important;cursor:pointer !important;margin:0 4px 4px 0 !important;padding:2px !important;height:20px}.fvch-toolbox .fvch-toolbox-icon:last-child{margin-right:0 !important}td.fvch-line-number{text-align:right;color:#666;width:1%;min-width:30px;padding:0 .5em;background:#e2e2e2;border-right:1px solid #d2d2d2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}td.fvch-line-number:before{content:attr(data-line-number)}.general{color:#000;font-weight:normal}.general-number{color:#f00}.general-operator{color:#00f}.general-brackets{color:#009}.general-string{color:#c00}.bash{color:#000}.bash-comment{color:#999}.bash-number{color:#f00}.bash-operator{color:#00f}.bash-brackets{color:#009}.bash-command{color:#060}.bash-string{color:#c00}.css{color:#f0f}.css-background{background-color:#fff}.css-import{color:#099;font-weight:bold}.css-media{color:#900;font-weight:bold}.css-comment{color:#999}.css-important{color:#f00;font-weight:bold}.css-property{color:#009}.css-selector{color:#f0f}.css-string{color:#060;font-weight:normal}.css-value{color:#00f}.css-rest{color:#f0f;font-weight:bold}.html{font-weight:normal;color:#000}.html-anchor-element{color:#060}.html-attribute{color:#00f}.html-comment{color:#999}.html-form-element{color:#f90}.html-image-element{color:#909}.html-object-element{color:#900}.html-other-element{color:#009}.html-script-element{color:#900}.html-special-char{color:#000;font-weight:bold}.html-style-element{color:#909}.html-table-element{color:#099}.html-text{color:#000}.php{color:#000;font-weight:normal}.php-script-tag{color:#d00;font-weight:bold}.php-comment{color:#f90}.php-constant{color:#520}.php-function{color:#00f}.php-number{color:#f00}.php-operator{color:#00f}.php-brackets{color:#009}.php-keyword{color:#006600}.php-string{color:#c00}.php-var-type{color:#099}.php-var{color:#06f}.xml{color:#000}.xml-string{color:#060}.xml-comment,.xml-comment span{color:#999}.xml-number{color:#f00}.xml-element{color:#009}.xml-text{color:#000}.javascript{color:#000}.js-string{color:#00f}.js-bracket{color:#009;font-weight:bold}.js-client-keyword{color:#909}.js-comment{color:#999}.js-function-keyword{color:#000;font-weight:bold}.js-native-keyword{color:#099}.js-number{color:#f00}.js-operator{color:#00f}.js-regexp{color:#060}.js-reserved-keyword{color:#009;font-weight:bold}.js-string{color:#00f}1 .fvch-hide-if-no-js{display:none !important}.fvch-codeblock{background:url(../images/notepaper.png) top left repeat;border:1px solid #d2d2d2;padding:0 !important;margin:0 0 1em;border-radius:3px;overflow-x:auto;position:relative}.fvch-codeblock table,.fvch-codeblock tbody,.fvch-codeblock tr,.fvch-codeblock td,.fvch-codeblock pre{padding:0;margin:0;border:none}.fvch-codeblock pre{white-space:pre;padding-left:.5em;font-family:"Monaco", "Courier New", Courier, monospace;border:none !important;background:none !important;color:inherit !important}.fvch-toolbox{position:absolute;top:0;right:0;display:none;border-left:1px solid #d2d2d2;border-bottom:1px solid #d2d2d2;border-bottom-left-radius:3px;border-top-right-radius:3px;background:#fff;padding:3px 6px 0}.fvch-codeblock:hover .fvch-toolbox{display:block}.fvch-toolbox .fvch-toolbox-icon{border:none !important;background:none !important;cursor:pointer !important;margin:0 4px 4px 0 !important;padding:2px !important;height:20px}.fvch-toolbox .fvch-toolbox-icon:last-child{margin-right:0 !important}td.fvch-line-number{text-align:right;color:#666;width:1%;min-width:30px;padding:0 .5em;background:#e2e2e2;border-right:1px solid #d2d2d2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}td.fvch-line-number:before{content:attr(data-line-number)}table.fvch-code tr:first-child td{padding-top:5px}table.fvch-code tr:last-child td{padding-bottom:5px}.general{color:#000;font-weight:normal}.general-number{color:#2934d4}.general-operator{color:#000}.general-brackets{color:#009}.general-string{color:#cf3125}.bash{color:#000}.bash-comment{color:#008312}.bash-number{color:#2934d4}.bash-operator{color:#000}.bash-brackets{color:#009}.bash-command{color:#b833a1}.bash-string{color:#cf3125}.css{color:#f0f}.css-background{background-color:#fff}.css-import{color:#099;font-weight:bold}.css-media{color:#900;font-weight:bold}.css-comment{color:#999}.css-important{color:#f00;font-weight:bold}.css-property{color:#009}.css-selector{color:#f0f}.css-string{color:#060;font-weight:normal}.css-value{color:#00f}.css-rest{color:#f0f;font-weight:bold}.html{font-weight:normal;color:#000}.html-anchor-element{color:#060}.html-attribute{color:#00f}.html-comment{color:#999}.html-form-element{color:#f90}.html-image-element{color:#909}.html-object-element{color:#900}.html-other-element{color:#009}.html-script-element{color:#900}.html-special-char{color:#000;font-weight:bold}.html-style-element{color:#909}.html-table-element{color:#099}.html-text{color:#000}.php{color:#000;font-weight:normal}.php-script-tag{color:#7c226d;font-weight:bold}.php-comment{color:#008312}.php-comment-phpdoc{color:#00500b}.php-constant{color:#77492d}.php-function{color:#3d237f}.php-method{color:#33595d}.php-class{color:#508187}.php-number{color:#2934d4}.php-operator{color:#000}.php-brackets{color:#009}.php-keyword{color:#b833a1}.php-string{color:#cf3125}.php-var-type{color:#6f41a7}.php-var{color:#508187}.xml{color:#000}.xml-string{color:#060}.xml-comment,.xml-comment span{color:#999}.xml-number{color:#f00}.xml-element{color:#009}.xml-text{color:#000}.javascript{color:#000}.js-string{color:#00f}.js-bracket{color:#009;font-weight:bold}.js-client-keyword{color:#909}.js-comment{color:#999}.js-function-keyword{color:#000;font-weight:bold}.js-native-keyword{color:#099}.js-number{color:#f00}.js-operator{color:#00f}.js-regexp{color:#060}.js-reserved-keyword{color:#009;font-weight:bold}.js-string{color:#00f} -
fv-code-highlighter/tags/2.0.2/readme.txt
r1773975 r1787934 6 6 Requires at least: 3.2 7 7 Tested up to: 4.9 8 Stable tag: 2.0. 18 Stable tag: 2.0.2 9 9 10 Highlight your code , Dreamweaver style.10 Highlight your code with beautiful highlighters. 11 11 12 12 … … 43 43 In order to successfully use this plugin, you will need the following: 44 44 45 * PHP 5 or higher45 * PHP 5.6 or higher 46 46 * WordPress 3.2 or higher 47 47 … … 86 86 87 87 88 = 2.0.2 = 89 90 * New: New Xcode inspired color scheme for PHP. 91 * New: PHP highlighter now also highlights classes, methods and phpdoc. 92 * Improvement: Stylesheet is minified. 93 * Improvement: Colorscheme stylesheet is dynamically loaded. 94 * Change: Font-size unit is changed from px to em. 95 96 88 97 = 2.0 = 89 98 -
fv-code-highlighter/tags/2.0.2/src/Admin/Options.php
r1765448 r1787934 72 72 <div class="fvch-support"> 73 73 <a href="https://www.paypal.me/FrankVerhoeven" class="button button-primary"> 74 <?php _e(' Donate me a beer :)', 'fvch'); ?>74 <?php _e('Support this plugin', 'fvch'); ?> 75 75 </a> 76 76 </div> … … 107 107 <td> 108 108 <select name="fvch-font-size" id="fvch-font-size"> 109 <?php for ($i =9; $i<=13; $i++) : ?>109 <?php for ($i = .5; $i < 2.1; $i += .1) : ?> 110 110 <option <?php selected($this->options->getOption('fvch-font-size'), $i); ?> value="<?php echo $i; ?>"><?php echo $i; ?></option> 111 111 <?php endfor; ?> 112 112 </select> 113 px 113 <code>em</code> 114 <p class="description"><?php _e('Using a font-size greater than 17px in combination with the notepaper background might cause display issues.', 'fvch'); ?></p> 114 115 </td> 115 116 </tr> -
fv-code-highlighter/tags/2.0.2/src/Application/Bootstrap.php
r1770114 r1787934 82 82 83 83 add_action('wp_head', [$output, 'displayHead']); 84 add_action('wp_footer', [$output, 'displayFooter']); 84 85 } 85 86 -
fv-code-highlighter/tags/2.0.2/src/Cache.php
r1765448 r1787934 3 3 namespace FvCodeHighlighter; 4 4 5 use Exception;5 use InvalidArgumentException; 6 6 7 7 /** 8 * FvCodeHighlighter_Cache8 * Cache 9 9 * 10 10 * @author Frank Verhoeven <[email protected]> … … 15 15 * @var string 16 16 */ 17 protected $cacheDir; 18 17 protected $cacheDirectory; 19 18 /** 20 19 * @var bool 21 20 */ 22 protected $enabled = true;21 protected $enabled; 23 22 24 23 /** 25 * __construct() 24 * Create a new cache handler with the provided cache directory. 25 * Caching is automatically disabled if the given directory is not 26 * writable or WP_DEBUG is set to true. 26 27 * 27 * @param string $cacheDir 28 * @version 20171 10328 * @param string $cacheDirectory 29 * @version 20171216 29 30 */ 30 public function __construct($cacheDir )31 public function __construct($cacheDirectory) 31 32 { 32 $this->cacheDir = realpath($cacheDir) . '/';33 $this->cacheDirectory = realpath($cacheDirectory) . '/'; 33 34 34 // Disable cache if $cacheDir is not writable, or if we're debugging 35 if (!wp_is_writable($cacheDir) || true === WP_DEBUG) { 35 if (!wp_is_writable($cacheDirectory) || true === WP_DEBUG) { 36 36 $this->enabled = false; 37 37 } … … 39 39 40 40 /** 41 * setCacheDir() 41 * Check if the cache file exists. 42 * Returns false if cache is disabled. 42 43 * 43 * @param string $ dir44 * @return $this45 * @version 20171 10344 * @param string $filename 45 * @return bool 46 * @version 20171216 46 47 */ 47 public function setCacheDir($dir)48 public function cacheFileExists($filename) 48 49 { 49 $this->cacheDir = $dir; 50 return $this; 50 return $this->enabled && file_exists($this->cacheDirectory . $filename); 51 51 } 52 52 53 53 /** 54 * getCacheDir()54 * Create a new cache file if cache is enabled. 55 55 * 56 * @return string 57 * @version 20171103 56 * @param string $filename 57 * @param string $content 58 * @version 20171216 58 59 */ 59 public function getCacheDir()60 public function createCacheFile($filename, $content) 60 61 { 61 return $this->cacheDir; 62 if ($this->enabled) { 63 file_put_contents($this->cacheDirectory . $filename, $content); 64 } 65 } 66 67 /** 68 * Get the content of a cache file. 69 * Returns null if cache is disabled. 70 * An InvalidArgumentException is thrown if the cache file does not exist. 71 * 72 * @param string $filename 73 * @return string|null 74 * @throws InvalidArgumentException 75 * @version 20171216 76 */ 77 public function getCacheFile($filename) 78 { 79 if (!$this->enabled) { 80 return null; 81 } 82 if (!$this->cacheFileExists($filename)) { 83 throw new InvalidArgumentException('The requested cache file does not exist'); 84 } 85 86 return file_get_contents($this->cacheDirectory . $filename); 62 87 } 63 88 64 89 /** 65 * cacheFileExists()90 * Clear the entire cache by removing all files in the cache directory. 66 91 * 67 * @param string $name 68 * @return bool 69 * @version 20171103 70 */ 71 public function cacheFileExists($name) 72 { 73 if (!$this->enabled) 74 return false; 75 76 return file_exists($this->getCacheDir() . $name); 77 } 78 79 /** 80 * createCacheFile() 81 * 82 * @param string $name 83 * @param string $content 84 * @return $this 85 * @version 20171103 86 */ 87 public function createCacheFile($name, $content) 88 { 89 if (!$this->enabled) 90 return $this; 91 92 file_put_contents($this->getCacheDir() . $name, $content); 93 return $this; 94 } 95 96 /** 97 * getCacheFile() 98 * 99 * @param string $name 100 * @return string 101 * @throws Exception 102 * @version 20171103 103 */ 104 public function getCacheFile($name) 105 { 106 if (!$this->enabled) 107 return $this; 108 109 if (!$this->cacheFileExists($name)) { 110 throw new Exception('The requested cache file does not exist'); 111 } 112 113 return file_get_contents($this->getCacheDir() . $name); 114 } 115 116 /** 117 * clear() 118 * 119 * @return $this 120 * @version 20171103 92 * @return void 93 * @version 20171216 121 94 */ 122 95 public function clear() 123 96 { 124 if (!$this->enabled) 125 return $this; 97 if ($this->enabled && $handle = opendir($this->cacheDirectory)) { 98 while (false !== ($file = readdir($handle))) { 99 if ('.' != $file && '..' != $file) { 100 unlink($this->cacheDirectory . $file); 101 } 102 } 126 103 127 if ($dr = opendir($this->getCacheDir())) { 128 while (false !== ($file = readdir($dr))) { 129 if ('.' != $file && '..' != $file) { 130 unlink($this->getCacheDir() . $file); 131 } 132 } 133 134 closedir($dr); 135 } 136 137 return $this; 104 closedir($handle); 105 } 138 106 } 139 107 } -
fv-code-highlighter/tags/2.0.2/src/Highlighter/AbstractHighlighter.php
r1770114 r1787934 32 32 */ 33 33 public static $operators = [ 34 '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', ' `', '~', '.', ' and ', ' or ', ' xor '34 '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '.', ' and ', ' or ', ' xor ' 35 35 ]; 36 36 … … 40 40 public static $brackets = [ 41 41 '{', '}', '[', ']', '(', ')' 42 ]; 43 44 /** 45 * @var array List of valid method name chars 46 */ 47 public static $methodChars = [ 48 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 49 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 50 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 51 '_', 42 52 ]; 43 53 -
fv-code-highlighter/tags/2.0.2/src/Highlighter/Php/Factory.php
r1770114 r1787934 27 27 'start' => ['/*'], 28 28 'end' => ['*/'], 29 'cssClass' => 'php-comment' 29 'cssClass' => 'php-comment', 30 'children' => [Key::create(Php::$phpDoc, 'php-comment-phpdoc', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$')], 30 31 ]), 31 32 Block::create([ … … 33 34 'end' => ["\n", "?>"], 34 35 'cssClass' => 'php-comment', 35 'includeEnd' => false 36 'includeEnd' => false, 37 'children' => [Key::create(Php::$phpDoc, 'php-comment-phpdoc', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$')], 36 38 ]), 37 39 Block::create([ … … 46 48 'end' => ["'"], 47 49 'cssClass' => 'php-string', 48 'endPrefix' => '.*(?<!\\\)$|[\\\]{2}',50 'endPrefix' => '.*(?<!\\\)$|[\\\]{2}', 49 51 'endPrefixLength' => 2, 50 52 ]), … … 54 56 'end' => array_merge(Php::$whitespace, Php::$operators, Php::$brackets, [',', ';']), 55 57 'cssClass' => 'php-var', 56 'endIncluded' => false 58 'endIncluded' => false, 57 59 ]), 58 60 Key::create(Php::$operators, 'php-operator'), … … 60 62 Key::create(Php::$brackets, 'php-brackets'), 61 63 Key::create(Php::$varTypes, 'php-var-type', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 62 Key::create( Php::$constants, 'php-constant', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'),64 Key::create(array_merge(Php::$constants, ['strict_types']), 'php-constant', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 63 65 Key::create(Php::$keywords, 'php-keyword', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 64 66 Key::create(get_defined_functions()['internal'], 'php-function', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 67 Block::create([ 68 'start' => Php::$methodChars, 69 'end' => array_merge(Php::$whitespace, Php::$operators, [',', ';', '{', '}', '[', ']', ')', '->']), 70 'contains' => '[a-zA-Z0-9_]+', 71 'cssClass' => 'php-var', 72 'endIncluded' => false, 73 'startPrefix' => '(->)$', 74 'startPrefixLength' => 2, 75 ]), 76 Block::create([ 77 'start' => Php::$methodChars, 78 'end' => ['('], 79 'contains' => '[a-zA-Z0-9_]+', 80 'cssClass' => 'php-method', 81 'endIncluded' => false, 82 'startPrefix' => '(->)$', 83 'startPrefixLength' => 2, 84 ]), 85 Block::create([ 86 'start' => Php::$methodChars, 87 'end' => array_merge(Php::$whitespace, ['{', ';', '(', ' as']), 88 'cssClass' => 'php-class', 89 'endIncluded' => false, 90 'startPrefix' => '(use|as|class|new|namespace)[\s]+$', 91 'startPrefixLength' => 10, 92 ]), 93 Block::create([ 94 'start' => Php::$methodChars, 95 'end' => ['::'], 96 'contains' => '[a-zA-Z0-9_]+', 97 'cssClass' => 'php-class', 98 'endIncluded' => false, 99 'startPrefix' => '(\(|[\s])+$', 100 'startPrefixLength' => 10, 101 ]), 102 Block::create([ 103 'start' => Php::$methodChars, 104 'end' => ['('], 105 'contains' => '[a-zA-Z0-9_]+', 106 'cssClass' => 'php-method', 107 'endIncluded' => false, 108 'startPrefix' => '::$', 109 'startPrefixLength' => 2, 110 ]), 111 Block::create([ 112 'start' => Php::$methodChars, 113 'end' => ['('], 114 'cssClass' => 'php-method', 115 'endIncluded' => false, 116 'startPrefix' => '(function)[\s]+$', 117 'startPrefixLength' => 9, 118 ]), 119 Block::create([ 120 'start' => Php::$methodChars, 121 'end' => ['('], 122 'contains' => '[a-zA-Z0-9_]+', 123 'cssClass' => 'php-method', 124 'endIncluded' => false, 125 'startPrefix' => '[\!\(\+\-\=\*\/\&\%\^\.\<\>\?\s]+$', 126 'startPrefixLength' => 1, 127 ]), 65 128 ]; 66 129 -
fv-code-highlighter/tags/2.0.2/src/Highlighter/Php/Php.php
r1770114 r1787934 8 8 * Php 9 9 * 10 * @author Frank Verhoeven <hi@frankverhoeven.me>10 * '@author Frank Verhoeven <hi'@frankverhoeven.me> 11 11 */ 12 12 class Php extends AbstractHighlighter … … 346 346 ]; 347 347 348 public static $phpDoc = [ 349 '@api', 350 '@author', 351 '@category', 352 '@copyright', 353 '@deprecated', 354 '@example', 355 '@filesource', 356 '@global', 357 '@ignore', 358 '@internal', 359 '@license', 360 '@link', 361 '@method', 362 '@package', 363 '@param', 364 '@property', 365 '@property-read', 366 '@property-write', 367 '@return', 368 '@see', 369 '@since', 370 '@source', 371 '@subpackage', 372 '@throws', 373 '@todo', 374 '@uses', 375 '@used-by', 376 '@var', 377 '@version', 378 '@example', 379 '@internal', 380 '@inheritdoc', 381 '@link', 382 '@see', 383 ]; 384 348 385 public function __construct(array $elements) 349 386 { -
fv-code-highlighter/tags/2.0.2/src/Installer.php
r1760364 r1787934 57 57 ->updateOption('fvch_version', $this->options->getDefaultOption('fvch_version')); 58 58 59 // Migrate font-size from px to em 60 if ((float) $this->options->getOption('fvch-font-size') > 2) { 61 $this->options->updateOption('fvch-font-size', $this->options->getDefaultOption('fvch-font-size')); 62 } 63 59 64 $this->cache->clear(); 60 65 -
fv-code-highlighter/tags/2.0.2/src/Options.php
r1773975 r1787934 42 42 'fvch-cache-dir' => __DIR__ . '/../cache', 43 43 'fvch-font-family' => 'Monaco', 44 'fvch-font-size' => '1 1',44 'fvch-font-size' => '1', 45 45 'fvch-background' => '#ffffff', 46 46 'fvch-background-custom'=> '#f6f6f6', -
fv-code-highlighter/tags/2.0.2/src/Output.php
r1770114 r1787934 49 49 * @return string 50 50 * @version 20171118 51 * @throws \Exception 51 52 */ 52 53 public function highlightCode($content) … … 200 201 public function enqueueScripts() 201 202 { 202 $stylesheet = plugins_url('public/css/fvch-styles.min.css', dirname(__FILE__));203 if (file_exists(get_stylesheet_directory() . '/fvch-styles.css')) {204 $stylesheet = get_stylesheet_directory_uri() . '/fvch-styles.css';205 }206 207 wp_register_style('fvch-styles', $stylesheet, false, '1.2');208 wp_enqueue_style('fvch-styles');209 210 203 if ($this->options->getOption('fvch-toolbox')) { 211 204 wp_enqueue_script('fvch-toolbox', plugins_url('public/js/toolbox.min.js', dirname(__FILE__)), ['jquery'], '1.1', true); … … 236 229 $font = $font[$this->options->getOption('fvch-font-family')]; 237 230 238 $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . ' px';231 $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'em'; 239 232 ?> 240 233 <style type="text/css"> 241 234 .fvch-codeblock { 242 background: <?php echo $background; ?>; 235 background: <?php echo $background; ?> !important; 236 background-position-y: 4px !important; 243 237 } 244 238 245 239 .fvch-codeblock pre, .fvch-line-number { 246 line-height: <?php echo 'notepaper' == $this->options->getOption('fvch-background') ? '17px' : '1.4em'; ?> ;247 font-family: <?php echo $font; ?> ;248 font-size: <?php echo $fontSize; ?> ;240 line-height: <?php echo 'notepaper' == $this->options->getOption('fvch-background') ? '17px' : '1.4em'; ?> !important; 241 font-family: <?php echo $font; ?> !important; 242 font-size: <?php echo $fontSize; ?> !important; 249 243 } 250 244 </style> … … 252 246 <?php 253 247 } 248 249 /** 250 * Include the colors stylesheet in the footer to make it non-blocking. 251 * 252 * @return void 253 */ 254 public function displayFooter() 255 { 256 $stylesheet = plugins_url('public/css/fvch-styles.min.css', dirname(__FILE__)); 257 if (file_exists(get_stylesheet_directory() . '/fvch-styles.min.css')) { 258 $stylesheet = get_stylesheet_directory_uri() . '/fvch-styles.min.css'; 259 } 260 261 ?> 262 <script type="text/javascript"> 263 (function(){ 264 var stylesheet = document.createElement('link'); 265 stylesheet.rel = 'stylesheet'; 266 stylesheet.href = '<?= $stylesheet; ?>'; 267 stylesheet.type = 'text/css'; 268 stylesheet.media = 'screen'; 269 document.getElementsByTagName('head')[0].appendChild(stylesheet); 270 })(); 271 </script> 272 <?php 273 } 254 274 } -
fv-code-highlighter/tags/2.0.2/src/Parser/Element/Block.php
r1770114 r1787934 61 61 * @var string 62 62 */ 63 private $contains; 64 /** 65 * @var string 66 */ 63 67 private $cssClass; 64 68 /** … … 196 200 197 201 /** 202 * @return string|null 203 */ 204 public function getContains() 205 { 206 return $this->contains; 207 } 208 209 /** 198 210 * @return string 199 211 */ -
fv-code-highlighter/tags/2.0.2/src/Parser/Parser.php
r1770114 r1787934 147 147 148 148 if ($element instanceof Block && $this->findBlockStart($element, substr($this->code, $this->pointer))) { 149 $blockStart = $this->pointer; 149 150 if ($element->isStartIncluded()) { 150 151 $parsed = '<span class="' . $element->getCssClass() . '">'; … … 163 164 $endReached = false; 164 165 while (!$this->findBlockEnd($element, substr($this->code, $this->pointer))) { 166 if (!$this->isValidContains($element, substr($this->code, $this->pointer, 1))) { 167 $this->pointer = $blockStart; 168 $parsed = null; 169 $endReached = true; 170 break; 171 } 172 165 173 if (null !== ($children = $element->getChildren())) { 166 174 $childParsed = $this->findElement($children); … … 177 185 } 178 186 187 179 188 if ($this->pointer > $this->codeLength) { 180 189 $endReached = true; … … 277 286 278 287 /** 288 * Check if the provided char is valid for the current block 289 * 290 * @param Block $element 291 * @param string $char 292 * @return bool 293 */ 294 public function isValidContains(Block $element, $char) 295 { 296 if (null === $element->getContains()) { 297 return true; 298 } 299 300 return preg_match('/' . $element->getContains() . '/', $char); 301 } 302 303 /** 279 304 * Validate given prefix 280 305 * -
fv-code-highlighter/trunk/fv-code-highlighter.php
r1773975 r1787934 7 7 * Author: Frank Verhoeven 8 8 * Author URI: https://frankverhoeven.me/ 9 * Version: 2.0. 19 * Version: 2.0.2 10 10 */ 11 11 12 12 final class FvCodeHighlighter 13 13 { 14 const VERSION = '2.0. 1';14 const VERSION = '2.0.2'; 15 15 16 16 /** -
fv-code-highlighter/trunk/public/css/fvch-styles.min.css
r1773975 r1787934 1 .fvch-hide-if-no-js{display:none !important}.fvch-codeblock{background:url(../images/notepaper.png) top left repeat;border:1px solid #d2d2d2;padding:0 !important;margin:0 0 1em;border-radius:3px;overflow-x:auto;position:relative ;font-size:10px}.fvch-codeblock table,.fvch-codeblock thead,.fvch-codeblock tbody,.fvch-codeblock tr,.fvch-codeblock td,.fvch-codeblock pre{padding:0;margin:0;border:none}.fvch-codeblock pre{white-space:pre;padding-left:.5em;font-family:"Monaco", "Courier New", Courier, monospace;border:none !important;background:none !important;color:inherit !important}.fvch-toolbox{position:absolute;top:0;right:0;display:none;border-left:1px solid #d2d2d2;border-bottom:1px solid #d2d2d2;border-bottom-left-radius:3px;border-top-right-radius:3px;background:#fff;padding:3px 6px 0}.fvch-codeblock:hover .fvch-toolbox{display:block}.fvch-toolbox .fvch-toolbox-icon{border:none !important;background:none !important;cursor:pointer !important;margin:0 4px 4px 0 !important;padding:2px !important;height:20px}.fvch-toolbox .fvch-toolbox-icon:last-child{margin-right:0 !important}td.fvch-line-number{text-align:right;color:#666;width:1%;min-width:30px;padding:0 .5em;background:#e2e2e2;border-right:1px solid #d2d2d2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}td.fvch-line-number:before{content:attr(data-line-number)}.general{color:#000;font-weight:normal}.general-number{color:#f00}.general-operator{color:#00f}.general-brackets{color:#009}.general-string{color:#c00}.bash{color:#000}.bash-comment{color:#999}.bash-number{color:#f00}.bash-operator{color:#00f}.bash-brackets{color:#009}.bash-command{color:#060}.bash-string{color:#c00}.css{color:#f0f}.css-background{background-color:#fff}.css-import{color:#099;font-weight:bold}.css-media{color:#900;font-weight:bold}.css-comment{color:#999}.css-important{color:#f00;font-weight:bold}.css-property{color:#009}.css-selector{color:#f0f}.css-string{color:#060;font-weight:normal}.css-value{color:#00f}.css-rest{color:#f0f;font-weight:bold}.html{font-weight:normal;color:#000}.html-anchor-element{color:#060}.html-attribute{color:#00f}.html-comment{color:#999}.html-form-element{color:#f90}.html-image-element{color:#909}.html-object-element{color:#900}.html-other-element{color:#009}.html-script-element{color:#900}.html-special-char{color:#000;font-weight:bold}.html-style-element{color:#909}.html-table-element{color:#099}.html-text{color:#000}.php{color:#000;font-weight:normal}.php-script-tag{color:#d00;font-weight:bold}.php-comment{color:#f90}.php-constant{color:#520}.php-function{color:#00f}.php-number{color:#f00}.php-operator{color:#00f}.php-brackets{color:#009}.php-keyword{color:#006600}.php-string{color:#c00}.php-var-type{color:#099}.php-var{color:#06f}.xml{color:#000}.xml-string{color:#060}.xml-comment,.xml-comment span{color:#999}.xml-number{color:#f00}.xml-element{color:#009}.xml-text{color:#000}.javascript{color:#000}.js-string{color:#00f}.js-bracket{color:#009;font-weight:bold}.js-client-keyword{color:#909}.js-comment{color:#999}.js-function-keyword{color:#000;font-weight:bold}.js-native-keyword{color:#099}.js-number{color:#f00}.js-operator{color:#00f}.js-regexp{color:#060}.js-reserved-keyword{color:#009;font-weight:bold}.js-string{color:#00f}1 .fvch-hide-if-no-js{display:none !important}.fvch-codeblock{background:url(../images/notepaper.png) top left repeat;border:1px solid #d2d2d2;padding:0 !important;margin:0 0 1em;border-radius:3px;overflow-x:auto;position:relative}.fvch-codeblock table,.fvch-codeblock tbody,.fvch-codeblock tr,.fvch-codeblock td,.fvch-codeblock pre{padding:0;margin:0;border:none}.fvch-codeblock pre{white-space:pre;padding-left:.5em;font-family:"Monaco", "Courier New", Courier, monospace;border:none !important;background:none !important;color:inherit !important}.fvch-toolbox{position:absolute;top:0;right:0;display:none;border-left:1px solid #d2d2d2;border-bottom:1px solid #d2d2d2;border-bottom-left-radius:3px;border-top-right-radius:3px;background:#fff;padding:3px 6px 0}.fvch-codeblock:hover .fvch-toolbox{display:block}.fvch-toolbox .fvch-toolbox-icon{border:none !important;background:none !important;cursor:pointer !important;margin:0 4px 4px 0 !important;padding:2px !important;height:20px}.fvch-toolbox .fvch-toolbox-icon:last-child{margin-right:0 !important}td.fvch-line-number{text-align:right;color:#666;width:1%;min-width:30px;padding:0 .5em;background:#e2e2e2;border-right:1px solid #d2d2d2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}td.fvch-line-number:before{content:attr(data-line-number)}table.fvch-code tr:first-child td{padding-top:5px}table.fvch-code tr:last-child td{padding-bottom:5px}.general{color:#000;font-weight:normal}.general-number{color:#2934d4}.general-operator{color:#000}.general-brackets{color:#009}.general-string{color:#cf3125}.bash{color:#000}.bash-comment{color:#008312}.bash-number{color:#2934d4}.bash-operator{color:#000}.bash-brackets{color:#009}.bash-command{color:#b833a1}.bash-string{color:#cf3125}.css{color:#f0f}.css-background{background-color:#fff}.css-import{color:#099;font-weight:bold}.css-media{color:#900;font-weight:bold}.css-comment{color:#999}.css-important{color:#f00;font-weight:bold}.css-property{color:#009}.css-selector{color:#f0f}.css-string{color:#060;font-weight:normal}.css-value{color:#00f}.css-rest{color:#f0f;font-weight:bold}.html{font-weight:normal;color:#000}.html-anchor-element{color:#060}.html-attribute{color:#00f}.html-comment{color:#999}.html-form-element{color:#f90}.html-image-element{color:#909}.html-object-element{color:#900}.html-other-element{color:#009}.html-script-element{color:#900}.html-special-char{color:#000;font-weight:bold}.html-style-element{color:#909}.html-table-element{color:#099}.html-text{color:#000}.php{color:#000;font-weight:normal}.php-script-tag{color:#7c226d;font-weight:bold}.php-comment{color:#008312}.php-comment-phpdoc{color:#00500b}.php-constant{color:#77492d}.php-function{color:#3d237f}.php-method{color:#33595d}.php-class{color:#508187}.php-number{color:#2934d4}.php-operator{color:#000}.php-brackets{color:#009}.php-keyword{color:#b833a1}.php-string{color:#cf3125}.php-var-type{color:#6f41a7}.php-var{color:#508187}.xml{color:#000}.xml-string{color:#060}.xml-comment,.xml-comment span{color:#999}.xml-number{color:#f00}.xml-element{color:#009}.xml-text{color:#000}.javascript{color:#000}.js-string{color:#00f}.js-bracket{color:#009;font-weight:bold}.js-client-keyword{color:#909}.js-comment{color:#999}.js-function-keyword{color:#000;font-weight:bold}.js-native-keyword{color:#099}.js-number{color:#f00}.js-operator{color:#00f}.js-regexp{color:#060}.js-reserved-keyword{color:#009;font-weight:bold}.js-string{color:#00f} -
fv-code-highlighter/trunk/readme.txt
r1773975 r1787934 6 6 Requires at least: 3.2 7 7 Tested up to: 4.9 8 Stable tag: 2.0. 18 Stable tag: 2.0.2 9 9 10 Highlight your code , Dreamweaver style.10 Highlight your code with beautiful highlighters. 11 11 12 12 … … 43 43 In order to successfully use this plugin, you will need the following: 44 44 45 * PHP 5 or higher45 * PHP 5.6 or higher 46 46 * WordPress 3.2 or higher 47 47 … … 86 86 87 87 88 = 2.0.2 = 89 90 * New: New Xcode inspired color scheme for PHP. 91 * New: PHP highlighter now also highlights classes, methods and phpdoc. 92 * Improvement: Stylesheet is minified. 93 * Improvement: Colorscheme stylesheet is dynamically loaded. 94 * Change: Font-size unit is changed from px to em. 95 96 88 97 = 2.0 = 89 98 -
fv-code-highlighter/trunk/src/Admin/Options.php
r1765448 r1787934 72 72 <div class="fvch-support"> 73 73 <a href="https://www.paypal.me/FrankVerhoeven" class="button button-primary"> 74 <?php _e(' Donate me a beer :)', 'fvch'); ?>74 <?php _e('Support this plugin', 'fvch'); ?> 75 75 </a> 76 76 </div> … … 107 107 <td> 108 108 <select name="fvch-font-size" id="fvch-font-size"> 109 <?php for ($i =9; $i<=13; $i++) : ?>109 <?php for ($i = .5; $i < 2.1; $i += .1) : ?> 110 110 <option <?php selected($this->options->getOption('fvch-font-size'), $i); ?> value="<?php echo $i; ?>"><?php echo $i; ?></option> 111 111 <?php endfor; ?> 112 112 </select> 113 px 113 <code>em</code> 114 <p class="description"><?php _e('Using a font-size greater than 17px in combination with the notepaper background might cause display issues.', 'fvch'); ?></p> 114 115 </td> 115 116 </tr> -
fv-code-highlighter/trunk/src/Application/Bootstrap.php
r1770114 r1787934 82 82 83 83 add_action('wp_head', [$output, 'displayHead']); 84 add_action('wp_footer', [$output, 'displayFooter']); 84 85 } 85 86 -
fv-code-highlighter/trunk/src/Cache.php
r1765448 r1787934 3 3 namespace FvCodeHighlighter; 4 4 5 use Exception;5 use InvalidArgumentException; 6 6 7 7 /** 8 * FvCodeHighlighter_Cache8 * Cache 9 9 * 10 10 * @author Frank Verhoeven <[email protected]> … … 15 15 * @var string 16 16 */ 17 protected $cacheDir; 18 17 protected $cacheDirectory; 19 18 /** 20 19 * @var bool 21 20 */ 22 protected $enabled = true;21 protected $enabled; 23 22 24 23 /** 25 * __construct() 24 * Create a new cache handler with the provided cache directory. 25 * Caching is automatically disabled if the given directory is not 26 * writable or WP_DEBUG is set to true. 26 27 * 27 * @param string $cacheDir 28 * @version 20171 10328 * @param string $cacheDirectory 29 * @version 20171216 29 30 */ 30 public function __construct($cacheDir )31 public function __construct($cacheDirectory) 31 32 { 32 $this->cacheDir = realpath($cacheDir) . '/';33 $this->cacheDirectory = realpath($cacheDirectory) . '/'; 33 34 34 // Disable cache if $cacheDir is not writable, or if we're debugging 35 if (!wp_is_writable($cacheDir) || true === WP_DEBUG) { 35 if (!wp_is_writable($cacheDirectory) || true === WP_DEBUG) { 36 36 $this->enabled = false; 37 37 } … … 39 39 40 40 /** 41 * setCacheDir() 41 * Check if the cache file exists. 42 * Returns false if cache is disabled. 42 43 * 43 * @param string $ dir44 * @return $this45 * @version 20171 10344 * @param string $filename 45 * @return bool 46 * @version 20171216 46 47 */ 47 public function setCacheDir($dir)48 public function cacheFileExists($filename) 48 49 { 49 $this->cacheDir = $dir; 50 return $this; 50 return $this->enabled && file_exists($this->cacheDirectory . $filename); 51 51 } 52 52 53 53 /** 54 * getCacheDir()54 * Create a new cache file if cache is enabled. 55 55 * 56 * @return string 57 * @version 20171103 56 * @param string $filename 57 * @param string $content 58 * @version 20171216 58 59 */ 59 public function getCacheDir()60 public function createCacheFile($filename, $content) 60 61 { 61 return $this->cacheDir; 62 if ($this->enabled) { 63 file_put_contents($this->cacheDirectory . $filename, $content); 64 } 65 } 66 67 /** 68 * Get the content of a cache file. 69 * Returns null if cache is disabled. 70 * An InvalidArgumentException is thrown if the cache file does not exist. 71 * 72 * @param string $filename 73 * @return string|null 74 * @throws InvalidArgumentException 75 * @version 20171216 76 */ 77 public function getCacheFile($filename) 78 { 79 if (!$this->enabled) { 80 return null; 81 } 82 if (!$this->cacheFileExists($filename)) { 83 throw new InvalidArgumentException('The requested cache file does not exist'); 84 } 85 86 return file_get_contents($this->cacheDirectory . $filename); 62 87 } 63 88 64 89 /** 65 * cacheFileExists()90 * Clear the entire cache by removing all files in the cache directory. 66 91 * 67 * @param string $name 68 * @return bool 69 * @version 20171103 70 */ 71 public function cacheFileExists($name) 72 { 73 if (!$this->enabled) 74 return false; 75 76 return file_exists($this->getCacheDir() . $name); 77 } 78 79 /** 80 * createCacheFile() 81 * 82 * @param string $name 83 * @param string $content 84 * @return $this 85 * @version 20171103 86 */ 87 public function createCacheFile($name, $content) 88 { 89 if (!$this->enabled) 90 return $this; 91 92 file_put_contents($this->getCacheDir() . $name, $content); 93 return $this; 94 } 95 96 /** 97 * getCacheFile() 98 * 99 * @param string $name 100 * @return string 101 * @throws Exception 102 * @version 20171103 103 */ 104 public function getCacheFile($name) 105 { 106 if (!$this->enabled) 107 return $this; 108 109 if (!$this->cacheFileExists($name)) { 110 throw new Exception('The requested cache file does not exist'); 111 } 112 113 return file_get_contents($this->getCacheDir() . $name); 114 } 115 116 /** 117 * clear() 118 * 119 * @return $this 120 * @version 20171103 92 * @return void 93 * @version 20171216 121 94 */ 122 95 public function clear() 123 96 { 124 if (!$this->enabled) 125 return $this; 97 if ($this->enabled && $handle = opendir($this->cacheDirectory)) { 98 while (false !== ($file = readdir($handle))) { 99 if ('.' != $file && '..' != $file) { 100 unlink($this->cacheDirectory . $file); 101 } 102 } 126 103 127 if ($dr = opendir($this->getCacheDir())) { 128 while (false !== ($file = readdir($dr))) { 129 if ('.' != $file && '..' != $file) { 130 unlink($this->getCacheDir() . $file); 131 } 132 } 133 134 closedir($dr); 135 } 136 137 return $this; 104 closedir($handle); 105 } 138 106 } 139 107 } -
fv-code-highlighter/trunk/src/Highlighter/AbstractHighlighter.php
r1770114 r1787934 32 32 */ 33 33 public static $operators = [ 34 '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', ' `', '~', '.', ' and ', ' or ', ' xor '34 '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '.', ' and ', ' or ', ' xor ' 35 35 ]; 36 36 … … 40 40 public static $brackets = [ 41 41 '{', '}', '[', ']', '(', ')' 42 ]; 43 44 /** 45 * @var array List of valid method name chars 46 */ 47 public static $methodChars = [ 48 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 49 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 50 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 51 '_', 42 52 ]; 43 53 -
fv-code-highlighter/trunk/src/Highlighter/Php/Factory.php
r1770114 r1787934 27 27 'start' => ['/*'], 28 28 'end' => ['*/'], 29 'cssClass' => 'php-comment' 29 'cssClass' => 'php-comment', 30 'children' => [Key::create(Php::$phpDoc, 'php-comment-phpdoc', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$')], 30 31 ]), 31 32 Block::create([ … … 33 34 'end' => ["\n", "?>"], 34 35 'cssClass' => 'php-comment', 35 'includeEnd' => false 36 'includeEnd' => false, 37 'children' => [Key::create(Php::$phpDoc, 'php-comment-phpdoc', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$')], 36 38 ]), 37 39 Block::create([ … … 46 48 'end' => ["'"], 47 49 'cssClass' => 'php-string', 48 'endPrefix' => '.*(?<!\\\)$|[\\\]{2}',50 'endPrefix' => '.*(?<!\\\)$|[\\\]{2}', 49 51 'endPrefixLength' => 2, 50 52 ]), … … 54 56 'end' => array_merge(Php::$whitespace, Php::$operators, Php::$brackets, [',', ';']), 55 57 'cssClass' => 'php-var', 56 'endIncluded' => false 58 'endIncluded' => false, 57 59 ]), 58 60 Key::create(Php::$operators, 'php-operator'), … … 60 62 Key::create(Php::$brackets, 'php-brackets'), 61 63 Key::create(Php::$varTypes, 'php-var-type', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 62 Key::create( Php::$constants, 'php-constant', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'),64 Key::create(array_merge(Php::$constants, ['strict_types']), 'php-constant', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 63 65 Key::create(Php::$keywords, 'php-keyword', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 64 66 Key::create(get_defined_functions()['internal'], 'php-function', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'), 67 Block::create([ 68 'start' => Php::$methodChars, 69 'end' => array_merge(Php::$whitespace, Php::$operators, [',', ';', '{', '}', '[', ']', ')', '->']), 70 'contains' => '[a-zA-Z0-9_]+', 71 'cssClass' => 'php-var', 72 'endIncluded' => false, 73 'startPrefix' => '(->)$', 74 'startPrefixLength' => 2, 75 ]), 76 Block::create([ 77 'start' => Php::$methodChars, 78 'end' => ['('], 79 'contains' => '[a-zA-Z0-9_]+', 80 'cssClass' => 'php-method', 81 'endIncluded' => false, 82 'startPrefix' => '(->)$', 83 'startPrefixLength' => 2, 84 ]), 85 Block::create([ 86 'start' => Php::$methodChars, 87 'end' => array_merge(Php::$whitespace, ['{', ';', '(', ' as']), 88 'cssClass' => 'php-class', 89 'endIncluded' => false, 90 'startPrefix' => '(use|as|class|new|namespace)[\s]+$', 91 'startPrefixLength' => 10, 92 ]), 93 Block::create([ 94 'start' => Php::$methodChars, 95 'end' => ['::'], 96 'contains' => '[a-zA-Z0-9_]+', 97 'cssClass' => 'php-class', 98 'endIncluded' => false, 99 'startPrefix' => '(\(|[\s])+$', 100 'startPrefixLength' => 10, 101 ]), 102 Block::create([ 103 'start' => Php::$methodChars, 104 'end' => ['('], 105 'contains' => '[a-zA-Z0-9_]+', 106 'cssClass' => 'php-method', 107 'endIncluded' => false, 108 'startPrefix' => '::$', 109 'startPrefixLength' => 2, 110 ]), 111 Block::create([ 112 'start' => Php::$methodChars, 113 'end' => ['('], 114 'cssClass' => 'php-method', 115 'endIncluded' => false, 116 'startPrefix' => '(function)[\s]+$', 117 'startPrefixLength' => 9, 118 ]), 119 Block::create([ 120 'start' => Php::$methodChars, 121 'end' => ['('], 122 'contains' => '[a-zA-Z0-9_]+', 123 'cssClass' => 'php-method', 124 'endIncluded' => false, 125 'startPrefix' => '[\!\(\+\-\=\*\/\&\%\^\.\<\>\?\s]+$', 126 'startPrefixLength' => 1, 127 ]), 65 128 ]; 66 129 -
fv-code-highlighter/trunk/src/Highlighter/Php/Php.php
r1770114 r1787934 8 8 * Php 9 9 * 10 * @author Frank Verhoeven <hi@frankverhoeven.me>10 * '@author Frank Verhoeven <hi'@frankverhoeven.me> 11 11 */ 12 12 class Php extends AbstractHighlighter … … 346 346 ]; 347 347 348 public static $phpDoc = [ 349 '@api', 350 '@author', 351 '@category', 352 '@copyright', 353 '@deprecated', 354 '@example', 355 '@filesource', 356 '@global', 357 '@ignore', 358 '@internal', 359 '@license', 360 '@link', 361 '@method', 362 '@package', 363 '@param', 364 '@property', 365 '@property-read', 366 '@property-write', 367 '@return', 368 '@see', 369 '@since', 370 '@source', 371 '@subpackage', 372 '@throws', 373 '@todo', 374 '@uses', 375 '@used-by', 376 '@var', 377 '@version', 378 '@example', 379 '@internal', 380 '@inheritdoc', 381 '@link', 382 '@see', 383 ]; 384 348 385 public function __construct(array $elements) 349 386 { -
fv-code-highlighter/trunk/src/Installer.php
r1760364 r1787934 57 57 ->updateOption('fvch_version', $this->options->getDefaultOption('fvch_version')); 58 58 59 // Migrate font-size from px to em 60 if ((float) $this->options->getOption('fvch-font-size') > 2) { 61 $this->options->updateOption('fvch-font-size', $this->options->getDefaultOption('fvch-font-size')); 62 } 63 59 64 $this->cache->clear(); 60 65 -
fv-code-highlighter/trunk/src/Options.php
r1773975 r1787934 42 42 'fvch-cache-dir' => __DIR__ . '/../cache', 43 43 'fvch-font-family' => 'Monaco', 44 'fvch-font-size' => '1 1',44 'fvch-font-size' => '1', 45 45 'fvch-background' => '#ffffff', 46 46 'fvch-background-custom'=> '#f6f6f6', -
fv-code-highlighter/trunk/src/Output.php
r1770114 r1787934 49 49 * @return string 50 50 * @version 20171118 51 * @throws \Exception 51 52 */ 52 53 public function highlightCode($content) … … 200 201 public function enqueueScripts() 201 202 { 202 $stylesheet = plugins_url('public/css/fvch-styles.min.css', dirname(__FILE__));203 if (file_exists(get_stylesheet_directory() . '/fvch-styles.css')) {204 $stylesheet = get_stylesheet_directory_uri() . '/fvch-styles.css';205 }206 207 wp_register_style('fvch-styles', $stylesheet, false, '1.2');208 wp_enqueue_style('fvch-styles');209 210 203 if ($this->options->getOption('fvch-toolbox')) { 211 204 wp_enqueue_script('fvch-toolbox', plugins_url('public/js/toolbox.min.js', dirname(__FILE__)), ['jquery'], '1.1', true); … … 236 229 $font = $font[$this->options->getOption('fvch-font-family')]; 237 230 238 $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . ' px';231 $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'em'; 239 232 ?> 240 233 <style type="text/css"> 241 234 .fvch-codeblock { 242 background: <?php echo $background; ?>; 235 background: <?php echo $background; ?> !important; 236 background-position-y: 4px !important; 243 237 } 244 238 245 239 .fvch-codeblock pre, .fvch-line-number { 246 line-height: <?php echo 'notepaper' == $this->options->getOption('fvch-background') ? '17px' : '1.4em'; ?> ;247 font-family: <?php echo $font; ?> ;248 font-size: <?php echo $fontSize; ?> ;240 line-height: <?php echo 'notepaper' == $this->options->getOption('fvch-background') ? '17px' : '1.4em'; ?> !important; 241 font-family: <?php echo $font; ?> !important; 242 font-size: <?php echo $fontSize; ?> !important; 249 243 } 250 244 </style> … … 252 246 <?php 253 247 } 248 249 /** 250 * Include the colors stylesheet in the footer to make it non-blocking. 251 * 252 * @return void 253 */ 254 public function displayFooter() 255 { 256 $stylesheet = plugins_url('public/css/fvch-styles.min.css', dirname(__FILE__)); 257 if (file_exists(get_stylesheet_directory() . '/fvch-styles.min.css')) { 258 $stylesheet = get_stylesheet_directory_uri() . '/fvch-styles.min.css'; 259 } 260 261 ?> 262 <script type="text/javascript"> 263 (function(){ 264 var stylesheet = document.createElement('link'); 265 stylesheet.rel = 'stylesheet'; 266 stylesheet.href = '<?= $stylesheet; ?>'; 267 stylesheet.type = 'text/css'; 268 stylesheet.media = 'screen'; 269 document.getElementsByTagName('head')[0].appendChild(stylesheet); 270 })(); 271 </script> 272 <?php 273 } 254 274 } -
fv-code-highlighter/trunk/src/Parser/Element/Block.php
r1770114 r1787934 61 61 * @var string 62 62 */ 63 private $contains; 64 /** 65 * @var string 66 */ 63 67 private $cssClass; 64 68 /** … … 196 200 197 201 /** 202 * @return string|null 203 */ 204 public function getContains() 205 { 206 return $this->contains; 207 } 208 209 /** 198 210 * @return string 199 211 */ -
fv-code-highlighter/trunk/src/Parser/Parser.php
r1770114 r1787934 147 147 148 148 if ($element instanceof Block && $this->findBlockStart($element, substr($this->code, $this->pointer))) { 149 $blockStart = $this->pointer; 149 150 if ($element->isStartIncluded()) { 150 151 $parsed = '<span class="' . $element->getCssClass() . '">'; … … 163 164 $endReached = false; 164 165 while (!$this->findBlockEnd($element, substr($this->code, $this->pointer))) { 166 if (!$this->isValidContains($element, substr($this->code, $this->pointer, 1))) { 167 $this->pointer = $blockStart; 168 $parsed = null; 169 $endReached = true; 170 break; 171 } 172 165 173 if (null !== ($children = $element->getChildren())) { 166 174 $childParsed = $this->findElement($children); … … 177 185 } 178 186 187 179 188 if ($this->pointer > $this->codeLength) { 180 189 $endReached = true; … … 277 286 278 287 /** 288 * Check if the provided char is valid for the current block 289 * 290 * @param Block $element 291 * @param string $char 292 * @return bool 293 */ 294 public function isValidContains(Block $element, $char) 295 { 296 if (null === $element->getContains()) { 297 return true; 298 } 299 300 return preg_match('/' . $element->getContains() . '/', $char); 301 } 302 303 /** 279 304 * Validate given prefix 280 305 *
Note: See TracChangeset
for help on using the changeset viewer.