Note: this is a new feature only working in git.
Overview
The version in git offers tentative support for client-side syntax highlighting. Here is an example:
require('sputnik') return sputnik.new_wsapi_run_fn{ VERSIUM_PARAMS = { '/home/alice/sputnik/wiki-data/' }, BASE_URL = '/sputnik.ws', }
SyntaxHighlighter
Syntax highlighting is currently offered through Alex Gorbatchev's SyntaxHighlighter Javascript library.
The library has been wrapped in Lua as a module "syntaxhighlighter". (The module will be eventually offered as a rock.) The module offers two functions: get_javascript()
and get_css()
. They return CSS and Javascript for SyntaxHighlighter respectively.
Sputnik Integration
Syntax highlighting is integrated into Sputnik very loosely, through two new parameters: MORE_CSS
and MORE_JAVASCRIPT
. Basically, whatever those parameters are set to will get added to sputnik/style.css
and sputnik/scripts.js` respectively. (In both cases, the additional code will get appended in the very end.) For example:
require('sputnik.wsapi_app') require('syntaxhighlighter') return sputnik.wsapi_app.new{ VERSIUM_PARAMS = { '/home/yuri/sputnik/wiki-data/' }, BASE_URL = '/', PASSWORD_SALT = '81782374908127304891720389412', TOKEN_SALT = '81732489017238976476917863123', MORE_JAVASCRIPT = syntaxhighlighter.get_javascript{"Bash", "Lua", "Python"}, MORE_CSS = syntaxhighlighter.get_css(), }
(Note that the parameters need to be set in sputnik.ws
or sputnik.cgi
, because sputnik/config
node cannot require
additional modules.
Using
You can use highlighting by manually putting <pre>
tag around your code block:
<pre class="brush: lua">
require("sputnik")
</pre>
Alternatively, you can try the experimental "fenced code blocks" syntax, currently available in mainline:
~~~lua
require("sputnik")
~~~