2017-11-27 13:45:24 +03:00
|
|
|
# frozen_string_literal: true
|
2008-01-19 03:06:19 +03:00
|
|
|
##
|
|
|
|
# This Markup outputter is used for testing purposes.
|
|
|
|
|
2008-02-10 06:59:08 +03:00
|
|
|
class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
2008-01-19 03:06:19 +03:00
|
|
|
|
2010-12-20 06:22:49 +03:00
|
|
|
# :stopdoc:
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
##
|
|
|
|
# :section: Visitor
|
|
|
|
|
2008-01-19 03:06:19 +03:00
|
|
|
def start_accepting
|
|
|
|
@res = []
|
2010-04-01 11:45:16 +04:00
|
|
|
@list = []
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def end_accepting
|
|
|
|
@res
|
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_paragraph(paragraph)
|
2011-06-16 08:59:24 +04:00
|
|
|
@res << convert_flow(@am.flow(paragraph.text))
|
2010-04-01 11:45:16 +04:00
|
|
|
end
|
|
|
|
|
2010-12-20 06:22:49 +03:00
|
|
|
def accept_raw raw
|
|
|
|
@res << raw.parts.join
|
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_verbatim(verbatim)
|
2010-12-20 06:22:49 +03:00
|
|
|
@res << verbatim.text.gsub(/^(\S)/, ' \1')
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_list_start(list)
|
|
|
|
@list << case list.type
|
|
|
|
when :BULLET then
|
|
|
|
'*'
|
|
|
|
when :NUMBER then
|
|
|
|
'1'
|
|
|
|
else
|
|
|
|
list.type
|
|
|
|
end
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_list_end(list)
|
|
|
|
@list.pop
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_list_item_start(list_item)
|
|
|
|
@res << "#{' ' * (@list.size - 1)}#{@list.last}: "
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_list_item_end(list_item)
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_blank_line(blank_line)
|
|
|
|
@res << "\n"
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_heading(heading)
|
|
|
|
@res << "#{'=' * heading.level} #{heading.text}"
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def accept_rule(rule)
|
|
|
|
@res << '-' * rule.weight
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|
|
|
|
|
2010-12-20 06:22:49 +03:00
|
|
|
# :startdoc:
|
|
|
|
|
2008-01-19 03:06:19 +03:00
|
|
|
end
|