PHP code example of dominus77 / yii2-highlight-plugin

1. Go to this page and download the library: Download dominus77/yii2-highlight-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dominus77 / yii2-highlight-plugin example snippets


<pre><code>...</code></pre>

<pre><code class="php">...</code></pre>
<pre><code class="css">...</code></pre>
<pre><code class="json">...</code></pre>
...

<pre><code class="php hljs">...</code></pre>
<pre><code class="css hljs">...</code></pre>
<pre><code class="json hljs">...</code></pre>
...

php composer.phar 


/** $this \yii\web\View */
\dominus77\highlight\Plugin::register($this);


\dominus77\highlight\Plugin::$options = [
    'theme' => 'paraiso-dark',// Styles       
];
/** $this \yii\web\View */
\dominus77\highlight\Plugin::register($this);


\dominus77\highlight\Plugin::$options = [
    //...
    'lineNumbers' => true,    // Show line numbers
    'singleLine' => true,     // Show number if one line    
];
/** $this \yii\web\View */
\dominus77\highlight\Plugin::register($this);


\dominus77\highlight\Plugin::$options = [
    //...
    // Custom init Highlight
    'highlightInit' => new \yii\web\JsExpression("
        $('pre code').each(function(i, block) {
            hljs.highlightBlock(block);
        });
    "),
    // Custom init Highlight Line Numbers
    'lineNumbersInit' => new \yii\web\JsExpression("
        $('code.hljs').each(function(i, block) {
            hljs.lineNumbersBlock(block);
        });
    "),
];
/** $this \yii\web\View */
\dominus77\highlight\Plugin::register($this);