A [PicoCMS](https://picocms.org/) plugin that adds [GeSHi](https://github.com/GeSHi/geshi-1.0) syntax highlighting to code blocks.
ohnonot 46cdab7e2d added information about submodules and PicoPygments | 3 년 전 | |
---|---|---|
geshi-1.0 @ 3c12a7931d | 3 년 전 | |
.gitignore | 3 년 전 | |
.gitmodules | 3 년 전 | |
PicoGeSHi.php | 3 년 전 | |
README.md | 3 년 전 | |
cssbuild.php | 3 년 전 | |
default.template.css | 3 년 전 | |
overrides.css | 3 년 전 | |
picogeshi.yml | 3 년 전 | |
submodule-add.txt | 3 년 전 |
A PicoCMS plugin that adds GeSHi syntax highlighting to code blocks that have a language definition. GeSHi is written in PHP and runs server-side - if you care about not pushing javascript on your site's visitors, you might like this. It is not the newest but stable and pretty fast.
[ I have since developed the PicoPygments plugin (also here) because some of GeSHi's lexers haven't been updated for a very long time. ]
There are two ways - cloning the git repository, or manually downloading the plugin.
/plugin
directory.git clone --recurse-submodules https://$site.org/ohnonot/PicoGeSHi
, where $site
is either framagit
or notabug
.If you follow a few simple rules, you can always cd PicoGeSHi; git pull
to the newest version:
picogeshi.yml
config file to your PicoCMS install's /config
directory.custom
in their name (see .gitignore
) and edit /config/picogeshi.yml
to point to those. Currently this only applies to css_template
./plugin
directory.PicoGeSHi
folder that immediately contains PicoGeSHi.php
and some other files. In other words, from your PicoCMS install's base directory, you should have /plugins/PicoGeSHi/PicoGeSHi.php
(and some other files and directories)./plugins/PicoGeSHi
directory and delete the empty geshi-1.0
folder.geshi-1.0
folder again. Make sure your /plugins/PicoGeshi
folder now contains geshi-1.0/src/geshi.php
and related files.That should be enough.
As usual, you should copy the picogeshi.yml
configuration file to your PicoCMS installation's /config
folder and make your adjustments there.
You have a markdown article with a fenced code block. If you append a language keyword to the opening fence, this plugin will become active. Example:
## This is what I coded in Lua:
~~~lua
-- try to find themes in $HOME
themedir = os.getenv("HOME") .. '/.local/share/themes/'
~~~
will use Lua syntax highlighting for this block of code.
PicoCMS uses Parsedown and Parsedown Extra which is supposed to implement Markdown Extra, but I found that this particular feature is not as rich as outlined here:
~~~ .lua
or ~~~{.lua}
) the extra characters show up in the class, e.g.: <code class="language-{.lua">
.Strangely, GeSHi can handle this, but the plugin sanitizes these strings nevertheless.
Even Markdown Extra has no means to put a CSS class on inline code, but you can write it out as HTML. Instead of
I keyed in `while true; do echo Yes; done` without looking.
you have to write
I keyed in <code class="language-bash">while true; do echo Yes; done</code> without looking.
Please read picogeshi.yml
for more information.
GeSHi currently supports the following language definitions:
GeSHi has a mechanism built in to create stylesheets on the fly, but this plugin is not using it.
GeSHi's styling is not suitable to adapt syntax color schemes to the overall theme and is generally way too complex imho.
It wasn't easy to come up with a blueprint stylesheet (default.template.css
), but in the end it's quite short and easy to apply and adapt.
Get this repository here: