Warning: file_get_contents(https://wiki.obormot.net//&upname=pmpygment-7c3e90d581142707e969050624489245.html): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 144

Warning: file_get_contents(https://wiki.obormot.net//&upname=pmpygment-ba57b4c63eef88f92c25a709ab2fe6e1.html): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 144

Warning: file_get_contents(https://wiki.obormot.net//&upname=pmpygment-cc9340ca8cfce39667f13483f7b909fb.html): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 144
New OborWiki feature: syntax highlighting with pygments — OborWiki
Blog »

New OborWiki feature: syntax highlighting with pygments

December 24, 2017, at 07:42 PM by Obormot in Features, Updates (0 comments)

The Pm Pygment recipe is now installed on OborWiki (off by default; you can enable it via the Configurator). It adds syntax highlighting for code blocks, via the Pygments syntax highlighter.

The basic usage is simple:

(:sourcecode lang="go" style="rainbow_dash":)
package main
import "fmt"

func main() {
    fmt.Println("Hello World")
}
(:sourcecodeend:)

A neat trick, however, is that you can also use it with the Pastebin Embed (Added 2017-12-25: or Gist Embed) recipe—retrieving the raw text of the paste, and letting Pm Pygment do the syntax highlighting for you:

(:sourcecode lang="go" style="rainbow_dash":)
(:pastebin-embed T3rxzk4N raw no-pre:)
(:sourcecodeend:)

(Note that the no-pre argument to the (:pastebin-embed:) directive is required for this to work.)

Here’s a longer example:

(:sourcecode lang="cpp" style="manni":)
(:pastebin-embed svHLwueV raw no-pre:)
(:sourcecodeend:)

See the Pm Pygment info page for more detailed documentation/instructions.

Leave a reply
Your name (required):

Your comment (required):


Enter value: Captcha