Mecha CMS

Add extra functionality to the core engine.

Highlight

Table of Contents
  1. Usage 
  2. Usage in Markdown 
  3. Syntax Highlighter Theme 

Syntax highlighter that works server-side.

Download Version 2.0.1 Download Development Version

Something looks broken? We accept bounties to fix them faster.

Highlight.php is a server-side syntax highlighter written in PHP. It’s a port of highlight.js by Ivan Sagalaev that makes full use of the language and style definitions of the original JavaScript project.

Usage 

Add one of the language type available in .\lot\x\highlight\engine\i\@scrivo\highlight.php\Highlight\languages folder to the <code> element:

<pre><code class="php">&lt;?php

function foo($bar) {
    return 'baz';
}</code></pre>

Add lang- or language- prefix to the language type to make it a priority if you have multiple classes added to the <code> element:

<pre><code class="foo bar language-php baz">&lt;?php

function foo($bar) {
    return 'baz';
}</code></pre>

Without specifying a priority, this extension will try to use one of the most relevant language types between foo, bar and baz:

<pre><code class="foo bar baz">&lt;?php

function foo($bar) {
    return 'baz';
}</code></pre>

Usage in Markdown 

Use fenced code block syntax to add the language type to the <code> element in Markdown:

~~~ .php
<?php

function foo($bar) {
    return 'baz';
}
~~~

Syntax Highlighter Theme 

Set your preferred syntax highlighter theme to the skin property in .\lot\x\highlight\state.php file:

return [
    'skin' => 'agate', // ← this
    'state' => [ … ]
];

Or use the global state modifier to overwrite it in .\lot\layout\index.php file:

State::set('x.highlight.skin', 'agate');

0 Comments

No comments yet.