Sha256: 39092c38cce9b3eecd00e1aa03dc29601f10047dc444584904e51c383cd7c2aa
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 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[=text| 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[=text| 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.3.1 | book/text/text_editing/code.glyph |
glyph-0.5.2 | book/text/text_editing/code.glyph |