| #{li.label.gsub(/ /, ' ')} | }
end
else
fail "unknown list type"
end
print "<#{list_type}>"
list.contents.each do |item|
if item.kind_of? SM::Flow::LI
prefix = prefixer.call(item)
print prefix
display_flow_item(item, prefix)
else
display_flow_item(item)
end
end
print "#{list_type}>"
end
def display_verbatim_flow_item(item, prefix=@indent)
print("")
puts item.body
puts("")
end
private
ATTR_MAP = {
BOLD => "b>",
ITALIC => "i>",
CODE => "tt>"
}
def update_attributes(current, wanted)
str = ""
# first turn off unwanted ones
off = current & ~wanted
for quality in [ BOLD, ITALIC, CODE]
if (off & quality) > 0
str << "" + ATTR_MAP[quality]
end
end
# now turn on wanted
for quality in [ BOLD, ITALIC, CODE]
unless (wanted & quality).zero?
str << "<" << ATTR_MAP[quality]
end
end
print str
end
def tag(code)
print("<#{code}>")
print(yield)
print("#{code}>")
end
def escape(str)
str.
gsub(/&/n, '&').
gsub(/\"/n, '"').
gsub(/>/n, '>').
gsub(/ AnsiFormatter,
"bs" => OverstrikeFormatter,
"html" => HtmlFormatter,
"plain" => TextFormatter,
"simple" => SimpleFormatter,
}
def TextFormatter.list
FORMATTERS.keys.sort.join(", ")
end
def TextFormatter.for(name)
FORMATTERS[name.downcase]
end
end
end
|