diff options
Diffstat (limited to 'lib/rdoc/markup/to_test.rb')
-rw-r--r-- | lib/rdoc/markup/to_test.rb | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/lib/rdoc/markup/to_test.rb b/lib/rdoc/markup/to_test.rb index ce6aff6e9a..0afdb96a18 100644 --- a/lib/rdoc/markup/to_test.rb +++ b/lib/rdoc/markup/to_test.rb @@ -6,44 +6,58 @@ require 'rdoc/markup/formatter' class RDoc::Markup::ToTest < RDoc::Markup::Formatter + ## + # :section: Visitor + def start_accepting @res = [] + @list = [] end def end_accepting @res end - def accept_paragraph(am, fragment) - @res << fragment.to_s + def accept_paragraph(paragraph) + @res << paragraph.text + end + + def accept_verbatim(verbatim) + @res << verbatim.text end - def accept_verbatim(am, fragment) - @res << fragment.to_s + def accept_list_start(list) + @list << case list.type + when :BULLET then + '*' + when :NUMBER then + '1' + else + list.type + end end - def accept_list_start(am, fragment) - @res << fragment.to_s + def accept_list_end(list) + @list.pop end - def accept_list_end(am, fragment) - @res << fragment.to_s + def accept_list_item_start(list_item) + @res << "#{' ' * (@list.size - 1)}#{@list.last}: " end - def accept_list_item(am, fragment) - @res << fragment.to_s + def accept_list_item_end(list_item) end - def accept_blank_line(am, fragment) - @res << fragment.to_s + def accept_blank_line(blank_line) + @res << "\n" end - def accept_heading(am, fragment) - @res << fragment.to_s + def accept_heading(heading) + @res << "#{'=' * heading.level} #{heading.text}" end - def accept_rule(am, fragment) - @res << fragment.to_s + def accept_rule(rule) + @res << '-' * rule.weight end end |