Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 70

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 71

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 72

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 138

Warning: Undefined variable $opts in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: Trying to access array offset on value of type null in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: file_get_contents(https://rubaiyat.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: Undefined array key "theme" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 30

Warning: Undefined array key "lines" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 35

Warning: Undefined array key "hl" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 51

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 70

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 71

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 72

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 138

Warning: Undefined variable $opts in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: Trying to access array offset on value of type null in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: file_get_contents(https://rubaiyat.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: Undefined array key "theme" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 30

Warning: Undefined array key "lines" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 35

Warning: Undefined array key "hl" in /home/public/wiki.obormot.net/cookbook/pastebin-embed.php on line 51

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 70

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 71

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 72

Warning: Undefined variable $pagename in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 138

Warning: Undefined variable $opts in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: Trying to access array offset on value of type null in /home/public/wiki.obormot.net/cookbook/pmpygment.php on line 141

Warning: file_get_contents(https://rubaiyat.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