module RedCloth INLINE_FORMATTERS = [:textile, :footnote, :link] def self.convert(text) new(text).to_html(*INLINE_FORMATTERS) end module Inline FN_RE = / (\s+)? # getting spaces (\\)?%\{ # opening (.*?) # footnote \}# # closing /xm def footnote(text) text.gsub!(FN_RE) do |m| if $2 %[#{$1}%{#{$3}}] else %(#{$3}) end end end LINK_RE = / < ((?:https?|ftp):\/\/.*?) > /xm def link(text) text.gsub!(LINK_RE) do |m| %(#{$1}) end end end module Formatters module HTML def figure(options = {}) %[

#{options[:class]}
#{options[:class]}

] end def note(options = {}) %[

#{options[:text]}

] end def attention(options = {}) %[

#{options[:text]}

] end def file(options = {}) base_url = Kitabu.config[:base_url] if base_url url = File.join(base_url, options[:text]) else url = content $stderr << "\nYou're using `file. #{content}` but didn't set base_url in your configuration file.\n" end %[

Download #{options[:text]}

] end end end end RedCloth.send(:include, RedCloth::Inline)