Sha256: 86925bedc42c5206d8873e9c5b5ba556847cb8e7da57a53e4ec170df0debe5bb
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
txt[ If you're a programmer, chances are that you're going to include some source code in your articles and books. Glyph offers two ways to format code blocks effortlessly: the %>[codeblock], which simply wraps text into @<pre>@ and @<code>@ tags, or the %>[highlight]. The last one requires either &[coderay] or &[uv], but it provides syntax highlighting for the most common programming languages. Cosider the following piece of ruby code: ] highlight[=mediawiki| def find_child(&block) children.each do \|c\| c.descend do \|node, level\| return node if block.call(node) end end nil end =] p[It can be wrapped in a highlight macro, like so:] highlight[=mediawiki| highlight[\=ruby\| def find_child(&block) children.each do \\\/\|c\\\/\| c.descend do \\\/\|node, level\\\/\| return node if block.call(node) end end nil end \=] =] p[...to produce the following, using the $[filters.highlighter] highlighter:] highlight[=ruby| def find_child(&block) children.each do \|c\| c.descend do \|node, level\| return node if block.call(node) end end nil end =] box[Some Remarks| txt[ * Highlighters require some configuration. For more information on relevant configuration settings, see the =>[#cfg_filters|filters.*] configuration settings. * If you're using the %>[highlight] together within the %>[textile], you must wrap the macro call within @<notextile>@ tags. * You must always escape pipes (@\|@) with the code or the highlight macro. ] ]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
glyph-0.5.1 | book/text/text_editing/code.glyph |
glyph-0.5.0 | book/text/text_editing/code.glyph |