Adds automatically SyntaxHighlighter scripts and themes to your pages.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
syntaxhighlighter
MIT License
PicoSyntaxHighlighter.php
README.md

README.md

PicoSyntaxHighlighter

This plugin adds automatically SyntaxHighlighter scripts and themes to your Pico CMS pages.

/!\ This plugin is for the version 2 of Pico CMS. For previous versions, you have to use this release.

/!!\ I will no longer maintain this PicoSyntaxHighlighter plugin as I'm now using another syntax highlighting tool, PrismJS, for which I've created another plugin for Pico: PicoPrism.

SyntaxHighlighter was originally created in 2004 and is still (?) maintained by Alex Gorbatchev and is released under both MIT License and GPL License.

You can download SyntaxHighlighter and read the documentation at : http://alexgorbatchev.com/SyntaxHighlighter/.

The code of SyntaxHighlighter is available on GitHub : https://github.com/alexgorbatchev/SyntaxHighlighter.

Installation

/!\ No matter the way you install the plugin, it's mandatory you name the plugin folder PicoSyntaxHighlighter.

Using Git

Just move to your Pico CMS plugins directory and run:

git clone https://github.com/bricebou/PicoSyntaxHighlighter.git

and jump to the Configuration section below.

Otherwise

Download the latest zip archive from Github and unzip it inside the plugins/PicoSyntaxHighlighter/.

Usage

Configuration

Version 2 of Pico CMS introduces YAML configuration files.
Parameters for the Pico SyntaxHighlighter plugin can be inserted into the config/config.yml file or put in a specific .yml file inside the config folder.

PicoSyntaxHighlighter.enabled: true
# Select the theme for SyntaxHighlighter, from the syntaxhighlighter/styles folder :
# Default, Django, Eclipse, Emacs, FadeToGrey, MDUltra, Midnight, RDark
synhigh:
  theme: Emacs
# If "true", load the Autoloader script that dynamically load the brushes
# without having to load them all on the same page
# If true, you have to define the brushes you use on your pages
  autoloader: true
# If you use the autoloader, you have to define the brushes you use on your pages
# or all of them. The brushes can be found in the syntaxhighlighter/scripts folder. 
# You can specify your own aliases for the brushes.
  autobrush:
    "bash shell": Bash
    "txt plain text": Plain
    "js jscript javascript": JScript
    "tex latex": Latex
    "php": Php
    "xml xhtml xslt html": Xml

# If you don"t use the autoloader function, you have to declare here all the brushes you use
# on your pages ; all brushes declared here will be loaded on each page of your site.
# See the syntaxhighlighter/scripts folder
  brush:
    - Bash
    - Plain
    - JScript
    - Latex
    - Php
    - Xml
# Don't load SyntaxHighlighter on certain pages based on their template
# Use the pipe | as separator, without space ; case-sensitive.
  excluded_templates: "category|supcategory"

Content

In your content pages, you can use this code for example :

<pre class="brush:php">
'GCbooks' => array(
  'numeric' => array('id','rank','pages','rating'),
  'date' => array('publication','added','acquisition'),
  'string' => array('isbn','title','edition','description','comments','translator','artist'),
  'bool' => array('read'),
  'list' => array('authors','publisher','language','serie','format','genre','location'),
  'image' => array('cover','backpic'),
  'unknow' => array(''),
  'url' => array('web')
),
</pre>

If you are using the autoloader function and if you have specified your own alias, you can use both of these :

<pre class="brush:txt">
hihihi
</pre>
<pre class="brush:plain">
hihihi
</pre>

If you are loading the brushes the "normal way", you have to use the aliases defined in each brush file. For the plain text brush, two aliases are defined: text and plain, but not txt.

/!\ You have to escape some characters that are reserved for HTML, such as ", &, < and >. You can use online tools like this one.

Using a snippet with Sublime Text

Instead of typing the pre code each time, you can use a snippet like this one:

<snippet>
	<content><![CDATA[
<pre class="brush:${1:lang}">

</pre>
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>sxh</tabTrigger> -->
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>