#!/usr/bin/env ruby # encoding: utf-8 # Inline rep :link do |data| %{#{data[:title]}} end rep :anchor do |data| %{#{data[:title]}} end rep :fmi do |data| %{for more information on #{data[:topic]}, see #{data[:link]}} end rep :draftcomment do |data| %{Comment: #{data[:comment]}} end rep :todo do |data| %{TODO: #{data[:todo]}} end # Block rep :note do |data| css_class = data[:name].to_s.match(/[a-z0-9_-]/i) ? data[:name] : "note" %{
#{data[:name].to_s.capitalize}#{data[:text]}
} end rep :box do |data| %{
#{data[:title]}
#{data[:text]}
} end rep :codeblock do |data| %{

#{data[:text]}

} end rep :image do |data| interpret "img[@src[#{data[:src]}]#{data[:attrs].join}]" end rep :figure do |data| interpret %{div[@class[figure]#{data[:attrs].join}\\/img[@src[#{data[:src]}]]div[@class[caption]#{data[:caption]}]]} end rep :title do |data| %{

#{Glyph["document.title"]}

} end rep :subtitle do |data| %{

#{Glyph["document.subtitle"]}

} end rep :author do |data| %{
by #{Glyph["document.author"]}
} end rep :pubdate do |data| %{
#{data[:date]}
} end rep :revision do |data| %{
#{Glyph['document.revision']}
} end rep :navigation do |data| %{} end # Structure rep :document do |data| %{ #{data[:content]} } end rep :meta do |data| %{} end rep :head do |data| %{ #{Glyph["document.title"]} #{data[:author]} #{data[:copyright]} #{data[:content]} } end rep :style do |data| file = data[:file] case Glyph['document.styles'].to_s when 'embed' then style = "" case file.extname when ".css" then style = file_load file when ".sass", ".scss" then begin require 'sass' style = Sass::Engine.new(file_load(file), :syntax => file.extname.gsub(/^\./, '').to_sym).render rescue LoadError macro_error "Sass is not installed. Please run: gem install sass" rescue Exception raise end else macro_error "Extension '#{file.extname}' not supported." end %{} when 'import' then %{} when 'link' then %{} else macro_error "Value '#{Glyph['document.styles']}' not allowed for 'document.styles' setting" end end rep :toc do |data| %{

#{data[:title]}

    #{data[:descend_section].call(data[:document].structure, nil)}
} end rep :toc_item do |data| "
  • #{data[:title]}
  • " end rep :toc_sublist do |data| "
    1. #{data[:contents]}
  • \n" end rep :section do |data| css_class = data[:name].to_s.match(/[a-z0-9_-]/i) ? data[:name] : "section" title = data[:title] ? %{#{data[:title]}\n} : "" %{
    #{title}#{data[:content]}
    } end