Plugin Directory

Changeset 1787934


Ignore:
Timestamp:
12/16/2017 09:29:13 AM (8 years ago)
Author:
frankverhoeven
Message:

Push 2.0.2

Location:
fv-code-highlighter
Files:
2 added
2 deleted
31 edited
16 copied

Legend:

Unmodified
Added
Removed
  • fv-code-highlighter/tags/2.0.2/fv-code-highlighter.php

    r1773975 r1787934  
    77 * Author:      Frank Verhoeven
    88 * Author URI:  https://frankverhoeven.me/
    9  * Version:     2.0.1
     9 * Version:     2.0.2
    1010 */
    1111
    1212final class FvCodeHighlighter
    1313{
    14     const VERSION = '2.0.1';
     14    const VERSION = '2.0.2';
    1515
    1616    /**
  • 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  
    66Requires at least:  3.2
    77Tested up to:       4.9
    8 Stable tag:         2.0.1
     8Stable tag:         2.0.2
    99
    10 Highlight your code, Dreamweaver style.
     10Highlight your code with beautiful highlighters.
    1111
    1212
     
    4343In order to successfully use this plugin, you will need the following:
    4444
    45 * PHP 5 or higher
     45* PHP 5.6 or higher
    4646* WordPress 3.2 or higher
    4747
     
    8686
    8787
     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
    8897= 2.0 =
    8998
  • fv-code-highlighter/tags/2.0.2/src/Admin/Options.php

    r1765448 r1787934  
    7272    <div class="fvch-support">
    7373        <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'); ?>
    7575        </a>
    7676    </div>
     
    107107                <td>
    108108                    <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) : ?>
    110110                        <option <?php selected($this->options->getOption('fvch-font-size'), $i); ?> value="<?php echo $i; ?>"><?php echo $i; ?></option>
    111111                    <?php endfor; ?>
    112112                    </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>
    114115                </td>
    115116            </tr>
  • fv-code-highlighter/tags/2.0.2/src/Application/Bootstrap.php

    r1770114 r1787934  
    8282
    8383        add_action('wp_head',               [$output, 'displayHead']);
     84        add_action('wp_footer',             [$output, 'displayFooter']);
    8485    }
    8586
  • fv-code-highlighter/tags/2.0.2/src/Cache.php

    r1765448 r1787934  
    33namespace FvCodeHighlighter;
    44
    5 use Exception;
     5use InvalidArgumentException;
    66
    77/**
    8  * FvCodeHighlighter_Cache
     8 * Cache
    99 *
    1010 * @author Frank Verhoeven <[email protected]>
     
    1515     * @var string
    1616     */
    17     protected $cacheDir;
    18 
     17    protected $cacheDirectory;
    1918    /**
    2019     * @var bool
    2120     */
    22     protected $enabled = true;
     21    protected $enabled;
    2322
    2423    /**
    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.
    2627     *
    27      * @param string $cacheDir
    28      * @version 20171103
     28     * @param string $cacheDirectory
     29     * @version 20171216
    2930     */
    30     public function __construct($cacheDir)
     31    public function __construct($cacheDirectory)
    3132    {
    32         $this->cacheDir = realpath($cacheDir) . '/';
     33        $this->cacheDirectory = realpath($cacheDirectory) . '/';
    3334
    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) {
    3636            $this->enabled = false;
    3737        }
     
    3939
    4040    /**
    41      * setCacheDir()
     41     * Check if the cache file exists.
     42     *  Returns false if cache is disabled.
    4243     *
    43      * @param string $dir
    44      * @return $this
    45      * @version 20171103
     44     * @param string $filename
     45     * @return bool
     46     * @version 20171216
    4647     */
    47     public function setCacheDir($dir)
     48    public function cacheFileExists($filename)
    4849    {
    49         $this->cacheDir = $dir;
    50         return $this;
     50        return $this->enabled && file_exists($this->cacheDirectory . $filename);
    5151    }
    5252
    5353    /**
    54      * getCacheDir()
     54     * Create a new cache file if cache is enabled.
    5555     *
    56      * @return string
    57      * @version 20171103
     56     * @param string $filename
     57     * @param string $content
     58     * @version 20171216
    5859     */
    59     public function getCacheDir()
     60    public function createCacheFile($filename, $content)
    6061    {
    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);
    6287    }
    6388
    6489    /**
    65      * cacheFileExists()
     90     * Clear the entire cache by removing all files in the cache directory.
    6691     *
    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
    12194     */
    12295    public function clear()
    12396    {
    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            }
    126103
    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        }
    138106    }
    139107}
  • fv-code-highlighter/tags/2.0.2/src/Highlighter/AbstractHighlighter.php

    r1770114 r1787934  
    3232     */
    3333    public static $operators = [
    34         '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '`', '~', '.', ' and ', ' or ', ' xor '
     34        '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '.', ' and ', ' or ', ' xor '
    3535    ];
    3636
     
    4040    public static $brackets = [
    4141        '{', '}', '[', ']', '(', ')'
     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        '_',
    4252    ];
    4353
  • fv-code-highlighter/tags/2.0.2/src/Highlighter/Php/Factory.php

    r1770114 r1787934  
    2727                'start' => ['/*'],
    2828                '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_]).*$')],
    3031            ]),
    3132            Block::create([
     
    3334                'end'   => ["\n", "?>"],
    3435                '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_]).*$')],
    3638            ]),
    3739            Block::create([
     
    4648                'end'   => ["'"],
    4749                'cssClass'  => 'php-string',
    48                 'endPrefix'=> '.*(?<!\\\)$|[\\\]{2}',
     50                'endPrefix' => '.*(?<!\\\)$|[\\\]{2}',
    4951                'endPrefixLength' => 2,
    5052            ]),
     
    5456                'end'   => array_merge(Php::$whitespace, Php::$operators, Php::$brackets, [',', ';']),
    5557                'cssClass'  => 'php-var',
    56                 'endIncluded'   => false
     58                'endIncluded'   => false,
    5759            ]),
    5860            Key::create(Php::$operators, 'php-operator'),
     
    6062            Key::create(Php::$brackets, 'php-brackets'),
    6163            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_]).*$'),
    6365            Key::create(Php::$keywords, 'php-keyword', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'),
    6466            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            ]),
    65128        ];
    66129
  • fv-code-highlighter/tags/2.0.2/src/Highlighter/Php/Php.php

    r1770114 r1787934  
    88 * Php
    99 *
    10  * @author Frank Verhoeven <hi@frankverhoeven.me>
     10 * '@author Frank Verhoeven <hi'@frankverhoeven.me>
    1111 */
    1212class Php extends AbstractHighlighter
     
    346346    ];
    347347
     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
    348385    public function __construct(array $elements)
    349386    {
  • fv-code-highlighter/tags/2.0.2/src/Installer.php

    r1760364 r1787934  
    5757            ->updateOption('fvch_version', $this->options->getDefaultOption('fvch_version'));
    5858
     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
    5964        $this->cache->clear();
    6065
  • fv-code-highlighter/tags/2.0.2/src/Options.php

    r1773975 r1787934  
    4242            'fvch-cache-dir'        => __DIR__ . '/../cache',
    4343            'fvch-font-family'      => 'Monaco',
    44             'fvch-font-size'        => '11',
     44            'fvch-font-size'        => '1',
    4545            'fvch-background'       => '#ffffff',
    4646            'fvch-background-custom'=> '#f6f6f6',
  • fv-code-highlighter/tags/2.0.2/src/Output.php

    r1770114 r1787934  
    4949     * @return string
    5050     * @version 20171118
     51     * @throws \Exception
    5152     */
    5253    public function highlightCode($content)
     
    200201    public function enqueueScripts()
    201202    {
    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 
    210203        if ($this->options->getOption('fvch-toolbox')) {
    211204            wp_enqueue_script('fvch-toolbox', plugins_url('public/js/toolbox.min.js', dirname(__FILE__)), ['jquery'], '1.1', true);
     
    236229        $font = $font[$this->options->getOption('fvch-font-family')];
    237230
    238         $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'px';
     231        $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'em';
    239232        ?>
    240233        <style type="text/css">
    241234            .fvch-codeblock {
    242                 background: <?php echo $background; ?>;
     235                background: <?php echo $background; ?> !important;
     236                background-position-y: 4px !important;
    243237            }
    244238
    245239            .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;
    249243            }
    250244        </style>
     
    252246        <?php
    253247    }
     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    }
    254274}
  • fv-code-highlighter/tags/2.0.2/src/Parser/Element/Block.php

    r1770114 r1787934  
    6161     * @var string
    6262     */
     63    private $contains;
     64    /**
     65     * @var string
     66     */
    6367    private $cssClass;
    6468    /**
     
    196200
    197201    /**
     202     * @return string|null
     203     */
     204    public function getContains()
     205    {
     206        return $this->contains;
     207    }
     208
     209    /**
    198210     * @return string
    199211     */
  • fv-code-highlighter/tags/2.0.2/src/Parser/Parser.php

    r1770114 r1787934  
    147147
    148148            if ($element instanceof Block && $this->findBlockStart($element, substr($this->code, $this->pointer))) {
     149                $blockStart = $this->pointer;
    149150                if ($element->isStartIncluded()) {
    150151                    $parsed = '<span class="' . $element->getCssClass() . '">';
     
    163164                $endReached = false;
    164165                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
    165173                    if (null !== ($children = $element->getChildren())) {
    166174                        $childParsed = $this->findElement($children);
     
    177185                    }
    178186
     187
    179188                    if ($this->pointer > $this->codeLength) {
    180189                        $endReached = true;
     
    277286
    278287    /**
     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    /**
    279304     * Validate given prefix
    280305     *
  • fv-code-highlighter/trunk/fv-code-highlighter.php

    r1773975 r1787934  
    77 * Author:      Frank Verhoeven
    88 * Author URI:  https://frankverhoeven.me/
    9  * Version:     2.0.1
     9 * Version:     2.0.2
    1010 */
    1111
    1212final class FvCodeHighlighter
    1313{
    14     const VERSION = '2.0.1';
     14    const VERSION = '2.0.2';
    1515
    1616    /**
  • 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  
    66Requires at least:  3.2
    77Tested up to:       4.9
    8 Stable tag:         2.0.1
     8Stable tag:         2.0.2
    99
    10 Highlight your code, Dreamweaver style.
     10Highlight your code with beautiful highlighters.
    1111
    1212
     
    4343In order to successfully use this plugin, you will need the following:
    4444
    45 * PHP 5 or higher
     45* PHP 5.6 or higher
    4646* WordPress 3.2 or higher
    4747
     
    8686
    8787
     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
    8897= 2.0 =
    8998
  • fv-code-highlighter/trunk/src/Admin/Options.php

    r1765448 r1787934  
    7272    <div class="fvch-support">
    7373        <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'); ?>
    7575        </a>
    7676    </div>
     
    107107                <td>
    108108                    <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) : ?>
    110110                        <option <?php selected($this->options->getOption('fvch-font-size'), $i); ?> value="<?php echo $i; ?>"><?php echo $i; ?></option>
    111111                    <?php endfor; ?>
    112112                    </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>
    114115                </td>
    115116            </tr>
  • fv-code-highlighter/trunk/src/Application/Bootstrap.php

    r1770114 r1787934  
    8282
    8383        add_action('wp_head',               [$output, 'displayHead']);
     84        add_action('wp_footer',             [$output, 'displayFooter']);
    8485    }
    8586
  • fv-code-highlighter/trunk/src/Cache.php

    r1765448 r1787934  
    33namespace FvCodeHighlighter;
    44
    5 use Exception;
     5use InvalidArgumentException;
    66
    77/**
    8  * FvCodeHighlighter_Cache
     8 * Cache
    99 *
    1010 * @author Frank Verhoeven <[email protected]>
     
    1515     * @var string
    1616     */
    17     protected $cacheDir;
    18 
     17    protected $cacheDirectory;
    1918    /**
    2019     * @var bool
    2120     */
    22     protected $enabled = true;
     21    protected $enabled;
    2322
    2423    /**
    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.
    2627     *
    27      * @param string $cacheDir
    28      * @version 20171103
     28     * @param string $cacheDirectory
     29     * @version 20171216
    2930     */
    30     public function __construct($cacheDir)
     31    public function __construct($cacheDirectory)
    3132    {
    32         $this->cacheDir = realpath($cacheDir) . '/';
     33        $this->cacheDirectory = realpath($cacheDirectory) . '/';
    3334
    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) {
    3636            $this->enabled = false;
    3737        }
     
    3939
    4040    /**
    41      * setCacheDir()
     41     * Check if the cache file exists.
     42     *  Returns false if cache is disabled.
    4243     *
    43      * @param string $dir
    44      * @return $this
    45      * @version 20171103
     44     * @param string $filename
     45     * @return bool
     46     * @version 20171216
    4647     */
    47     public function setCacheDir($dir)
     48    public function cacheFileExists($filename)
    4849    {
    49         $this->cacheDir = $dir;
    50         return $this;
     50        return $this->enabled && file_exists($this->cacheDirectory . $filename);
    5151    }
    5252
    5353    /**
    54      * getCacheDir()
     54     * Create a new cache file if cache is enabled.
    5555     *
    56      * @return string
    57      * @version 20171103
     56     * @param string $filename
     57     * @param string $content
     58     * @version 20171216
    5859     */
    59     public function getCacheDir()
     60    public function createCacheFile($filename, $content)
    6061    {
    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);
    6287    }
    6388
    6489    /**
    65      * cacheFileExists()
     90     * Clear the entire cache by removing all files in the cache directory.
    6691     *
    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
    12194     */
    12295    public function clear()
    12396    {
    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            }
    126103
    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        }
    138106    }
    139107}
  • fv-code-highlighter/trunk/src/Highlighter/AbstractHighlighter.php

    r1770114 r1787934  
    3232     */
    3333    public static $operators = [
    34         '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '`', '~', '.', ' and ', ' or ', ' xor '
     34        '=', '+', '/', '*', '&', '^', '%', ':', '?', '!', '-', '<', '>', '|', '~', '.', ' and ', ' or ', ' xor '
    3535    ];
    3636
     
    4040    public static $brackets = [
    4141        '{', '}', '[', ']', '(', ')'
     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        '_',
    4252    ];
    4353
  • fv-code-highlighter/trunk/src/Highlighter/Php/Factory.php

    r1770114 r1787934  
    2727                'start' => ['/*'],
    2828                '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_]).*$')],
    3031            ]),
    3132            Block::create([
     
    3334                'end'   => ["\n", "?>"],
    3435                '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_]).*$')],
    3638            ]),
    3739            Block::create([
     
    4648                'end'   => ["'"],
    4749                'cssClass'  => 'php-string',
    48                 'endPrefix'=> '.*(?<!\\\)$|[\\\]{2}',
     50                'endPrefix' => '.*(?<!\\\)$|[\\\]{2}',
    4951                'endPrefixLength' => 2,
    5052            ]),
     
    5456                'end'   => array_merge(Php::$whitespace, Php::$operators, Php::$brackets, [',', ';']),
    5557                'cssClass'  => 'php-var',
    56                 'endIncluded'   => false
     58                'endIncluded'   => false,
    5759            ]),
    5860            Key::create(Php::$operators, 'php-operator'),
     
    6062            Key::create(Php::$brackets, 'php-brackets'),
    6163            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_]).*$'),
    6365            Key::create(Php::$keywords, 'php-keyword', '^(?![a-zA-Z0-9_]).*$', '^(?![a-zA-Z0-9_]).*$'),
    6466            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            ]),
    65128        ];
    66129
  • fv-code-highlighter/trunk/src/Highlighter/Php/Php.php

    r1770114 r1787934  
    88 * Php
    99 *
    10  * @author Frank Verhoeven <hi@frankverhoeven.me>
     10 * '@author Frank Verhoeven <hi'@frankverhoeven.me>
    1111 */
    1212class Php extends AbstractHighlighter
     
    346346    ];
    347347
     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
    348385    public function __construct(array $elements)
    349386    {
  • fv-code-highlighter/trunk/src/Installer.php

    r1760364 r1787934  
    5757            ->updateOption('fvch_version', $this->options->getDefaultOption('fvch_version'));
    5858
     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
    5964        $this->cache->clear();
    6065
  • fv-code-highlighter/trunk/src/Options.php

    r1773975 r1787934  
    4242            'fvch-cache-dir'        => __DIR__ . '/../cache',
    4343            'fvch-font-family'      => 'Monaco',
    44             'fvch-font-size'        => '11',
     44            'fvch-font-size'        => '1',
    4545            'fvch-background'       => '#ffffff',
    4646            'fvch-background-custom'=> '#f6f6f6',
  • fv-code-highlighter/trunk/src/Output.php

    r1770114 r1787934  
    4949     * @return string
    5050     * @version 20171118
     51     * @throws \Exception
    5152     */
    5253    public function highlightCode($content)
     
    200201    public function enqueueScripts()
    201202    {
    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 
    210203        if ($this->options->getOption('fvch-toolbox')) {
    211204            wp_enqueue_script('fvch-toolbox', plugins_url('public/js/toolbox.min.js', dirname(__FILE__)), ['jquery'], '1.1', true);
     
    236229        $font = $font[$this->options->getOption('fvch-font-family')];
    237230
    238         $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'px';
     231        $fontSize = esc_attr($this->options->getOption('fvch-font-size')) . 'em';
    239232        ?>
    240233        <style type="text/css">
    241234            .fvch-codeblock {
    242                 background: <?php echo $background; ?>;
     235                background: <?php echo $background; ?> !important;
     236                background-position-y: 4px !important;
    243237            }
    244238
    245239            .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;
    249243            }
    250244        </style>
     
    252246        <?php
    253247    }
     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    }
    254274}
  • fv-code-highlighter/trunk/src/Parser/Element/Block.php

    r1770114 r1787934  
    6161     * @var string
    6262     */
     63    private $contains;
     64    /**
     65     * @var string
     66     */
    6367    private $cssClass;
    6468    /**
     
    196200
    197201    /**
     202     * @return string|null
     203     */
     204    public function getContains()
     205    {
     206        return $this->contains;
     207    }
     208
     209    /**
    198210     * @return string
    199211     */
  • fv-code-highlighter/trunk/src/Parser/Parser.php

    r1770114 r1787934  
    147147
    148148            if ($element instanceof Block && $this->findBlockStart($element, substr($this->code, $this->pointer))) {
     149                $blockStart = $this->pointer;
    149150                if ($element->isStartIncluded()) {
    150151                    $parsed = '<span class="' . $element->getCssClass() . '">';
     
    163164                $endReached = false;
    164165                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
    165173                    if (null !== ($children = $element->getChildren())) {
    166174                        $childParsed = $this->findElement($children);
     
    177185                    }
    178186
     187
    179188                    if ($this->pointer > $this->codeLength) {
    180189                        $endReached = true;
     
    277286
    278287    /**
     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    /**
    279304     * Validate given prefix
    280305     *
Note: See TracChangeset for help on using the changeset viewer.