Sha256: af023549cbdd41fb595f5645efc333d83ba9aa33dfba6e0fc27a4dbad8b925bf
Contents?: true
Size: 1.5 KB
Versions: 3
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[=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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
glyph-0.4.2 | book/text/text_editing/code.glyph |
glyph-0.4.1 | book/text/text_editing/code.glyph |
glyph-0.4.0 | book/text/text_editing/code.glyph |