From: Jean Privat Date: Thu, 10 Sep 2015 02:45:55 +0000 (-0400) Subject: nitiwiki: extends the example with an external highlighter X-Git-Tag: v0.7.8~32^2~1 X-Git-Url: http://nitlanguage.org nitiwiki: extends the example with an external highlighter Signed-off-by: Jean Privat --- diff --git a/contrib/nitiwiki/examples/nitiwiki/config.ini b/contrib/nitiwiki/examples/nitiwiki/config.ini index 315462d..bc96f38 100644 --- a/contrib/nitiwiki/examples/nitiwiki/config.ini +++ b/contrib/nitiwiki/examples/nitiwiki/config.ini @@ -3,3 +3,4 @@ wiki.desc=proudly powered by nit wiki.logo=assets/logo.png wiki.root_dir=. wiki.rsync_dir=moz-code.org:nitiwiki/ +wiki.highlighter=./highlighter.sh "$1" diff --git a/contrib/nitiwiki/examples/nitiwiki/highlighter.sh b/contrib/nitiwiki/examples/nitiwiki/highlighter.sh new file mode 100755 index 0000000..57aaf45 --- /dev/null +++ b/contrib/nitiwiki/examples/nitiwiki/highlighter.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Example of an external highlighter that dispatch on various command +# according to the argument + +# meta is the argument +meta=$1 + +# raw is a synonym of txt +test "$meta" = "raw" && meta=txt + +# if `pandoc` then process through the `pandoc` command. +if test "$meta" = "pandoc"; then + exec pandoc -t html +fi + +# Else, try `highlight` +highlight --fragment -S "$meta" --inline-css --enclose-pre || + # Or `source-highlight` + source-highlight -s "$meta" +out=$? +exit $out diff --git a/contrib/nitiwiki/examples/nitiwiki/pages/block.md b/contrib/nitiwiki/examples/nitiwiki/pages/block.md new file mode 100644 index 0000000..d0daaba --- /dev/null +++ b/contrib/nitiwiki/examples/nitiwiki/pages/block.md @@ -0,0 +1,36 @@ +# Test of code highlighting + +A basic block. + + print(["hello", "world"].join(", ")) + +A fenced block. + +~~~ +print(["hello", "world"].join(", ")) +~~~ + +A fenced block with metainfo, so it can be highlighted with an external tool. + +~~~html + + + +
HelloWorld
+~~~ + +A special block where the rendering is delegated to pandoc. +For instance, to render tables. + +~~~pandoc +what how +------ ----- +hello 10 +world 9001 +~~~ + +This try some exploit +~~~raw'"; echo pwned >&2 # +Hello
+World +~~~