Sha256: e982f8ed77277291a9c741a2d3dc2c46e169de3c30974c9ae4fa0aac756f0930
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
module RedCloth::Formatters::RDoc include RedCloth::Formatters::Base [1, 2, 3, 4, 5, 6].each do |level| define_method("h#{level}".to_sym) do |opts| "#{'=' * level} #{opts[:text]}\n\n" end end [:p, :pre, :div].each do |m| define_method(m) do |opts| "#{opts[:text]}\n\n" end end def strong(opts) "<b>#{opts[:text]}</b>" end alias_method :b, :strong def em(opts) "<em>#{opts[:text]}</em>" end alias_method :i, :em [:ol, :ul].each do |m| define_method("#{m}_open") do |opts| opts[:block] = true "" end define_method("#{m}_close") do |opts| "#{"\n" if opts[:nest] <= 1}" end end def li_open(opts) "#{"* " * opts[:nest]}#{opts[:text]}\n" end def li_close(opts=nil) "" end def td(opts) tdtype = opts[:th] ? 'th' : 'td' "\t\t<#{tdtype}#{pba(opts)}>#{opts[:text]}</#{tdtype}>\n" end def tr_open(opts) "\t<tr#{pba(opts)}>\n" end def tr_close(opts) "\t</tr>\n" end def table_open(opts) "<table#{pba(opts)}>\n" end def table_close(opts) "</table>\n\n" end def code(opts) if opts[:block] block = "" opts[:text].lines.each { |line| block += " #{line}" } return block end "<tt>#{opts[:text]}</tt>" end def bc_open(opts) opts[:block] = true "" end def bc_close(opts) opts[:block] = false "\n\n" end def link(opts) "{#{opts[:name]}}[#{opts[:href]}]" end def image(opts) "#{opts[:src]}" end private # escapement for regular HTML (not in PRE tag) def escape(text) text end # escapement for HTML in a PRE tag def escape_pre(text) text end # escaping for HTML attributes def escape_attribute(text) text end def after_transform(text) text.chomp! end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redcloth-formatters-rdoc-0.0.1 | lib/redcloth-formatters-rdoc/formatters/r_doc.rb |