2017 © Pedro Peláez
 

yii2-extension yii2-highlight-plugin

Yii2 Syntax highlighting with support for line numbering for the Web.

image

dominus77/yii2-highlight-plugin

Yii2 Syntax highlighting with support for line numbering for the Web.

  • Wednesday, May 2, 2018
  • by dominus77
  • Repository
  • 1 Watchers
  • 2 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 40 % Grown

The README.md

yii2-highlight-plugin

Latest Stable Version License Build Status codecov Scrutinizer Code Quality Total Downloads PayPal donate button SensioLabsInsight, (*1)

Yii2 Syntax highlighting with support for line numbering for the Web., (*2)

176 languages and 79 styles, (*3)

The plugin is based on highlight.js, added support for line numbering with the plugin highlightjs-line-numbers.js, (*4)

Auto language definition, (*5)

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

Explicit language specification, (*6)

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

Add class hljs, render full block code, (*7)

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

Watch demo, (*8)

Installation

The preferred way to install this extension is through composer., (*9)

Either run, (*10)

php composer.phar require dominus77/yii2-highlight-plugin "*"

or add, (*11)

"dominus77/yii2-highlight-plugin": "*"

to the require section of your composer.json file., (*12)

Usage

Once the extension is installed, simply use it in your code by View:, (*13)

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

Configure plugin

Theme

See the following link for supported topics Styles, (*14)

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

Line Numbers

By default, line numbers are disabled, (*15)

<?php
\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);

Custom init

<?php
\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);

Testing

$ phpunit

More Information

Please, check the highlight.js and highlightjs-line-numbers.js, (*16)

License

The MIT License (MIT). Please see License File for more information., (*17)

Sensio Labs

SensioLabsInsight, (*18)

The Versions

02/05 2018

dev-master

9999999-dev

Yii2 Syntax highlighting with support for line numbering for the Web.

  Sources   Download

MIT BSD-3-Clause

The Requires

 

The Development Requires

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers

16/01 2018

v1.1.2

1.1.2.0

Yii2 Syntax highlighting with support for line numbering for the Web.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers

02/12 2017

v1.1.1

1.1.1.0

Yii2 Syntax highlighting with support for line numbering for the Web.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers

02/12 2017

v1.1.0

1.1.0.0

Yii2 Syntax highlighting with support for line numbering for the Web.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers

06/10 2017

v1.0.1

1.0.1.0

Yii2 Syntax highlighting with support for line numbering for the Web.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers

04/10 2017

v1.0.0

1.0.0.0

Yii2 Syntax highlighting for the Web.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

plugin extension yii2 highlight dominus77 highlight-line-numbers