#!/usr/bin/env ruby macro :note do %{
#{@name.to_s.capitalize}#{@value}
} end macro :box do exact_parameters 2, :level => :warning %{
#{params[0]}
#{params[1]}
} end macro :code do min_parameters 1 %{

#{@value}

} end macro :highlight do min_parameters 2 lang = params[0] text = raw_params[1..raw_params.length-1].join '\\|' text.gsub!(/\\(.)/){$1} highlighter = Glyph["highlighters.current"].to_sym rescue nil if !highlighter then begin require 'coderay' highlighter = :coderay rescue LoadError begin require 'uv' highlighter = :ultraviolet rescue LoadError macro_error "No highlighter installed. Please run: gem install coderay" end end Glyph["highlighter.current"] = highlighter end target = Glyph["highlighters.target"] result = "" case highlighter.to_sym when :coderay begin require 'coderay' result = CodeRay.scan(text, lang).div(Glyph["highlighters.coderay"]) rescue LoadError macro_error "CodeRay highlighter not installed. Please run: gem install coderay" rescue Exception => e macro_error e.message end when :ultraviolet begin require 'uv' target = 'xhtml' if target == 'html' result = Uv.parse(text.to_s, target.to_s, lang.to_s, Glyph["highlighters.ultraviolet.line_numbers"], Glyph["highlighters.ultraviolet.theme"].to_s) rescue LoadError macro_error "UltraViolet highlighter not installed. Please run: gem install ultraviolet" rescue Exception => e puts e.backtrace macro_error e.message end else macro_error "No highlighter installed. Please run: gem install coderay" end result end macro :title do no_parameters %{

#{Glyph["document.title"]}

} end macro :img do min_parameters 1 max_parameters 3 image = params[0] width = params[1] source_file = Glyph.lite? ? image : Glyph::PROJECT/"images/#{image}" dest_file = Glyph.lite? ? image : "images/#{image}" w = (width) ? "width=\"#{width}\"" : '' height = params[2] h = (height) ? "height=\"#{height}\"" : '' Glyph.warning "Image '#{image}' not found" unless Pathname.new(dest_file).exist? %{-} end macro :fig do min_parameters 1 max_parameters 2 image = params[0] caption = params[1] caption ||= nil caption = %{
#{caption}
} if caption source_file = Glyph.lite? ? image : Glyph::PROJECT/"images/#{image}" dest_file = Glyph.lite? ? image : "images/#{image}" Glyph.warning "Figure '#{image}' not found" unless Pathname.new(dest_file).exist? %{
- #{caption}
} end macro :subtitle do no_parameters %{

#{Glyph["document.subtitle"]}

} end macro :author do no_parameters %{
by #{Glyph["document.author"]}
} end macro :pubdate do no_parameters %{
#{Time.now.strftime("%B %Y")}
} end macro :table do exact_parameters 1 %{ #{@value}
} end macro :tr do exact_parameters 1, :level => :warning %{ #{@value} } end macro :td do exact_parameters 1, :level => :warning %{ #{@value} } end macro :th do exact_parameters 1, :level => :warning %{#{@value}} end macro_alias :important => :note macro_alias :tip => :note macro_alias :caution => :note