1##
2# This Markup outputter is used for testing purposes.
3
4class RDoc::Markup::ToTest < RDoc::Markup::Formatter
5
6  # :stopdoc:
7
8  ##
9  # :section: Visitor
10
11  def start_accepting
12    @res = []
13    @list = []
14  end
15
16  def end_accepting
17    @res
18  end
19
20  def accept_paragraph(paragraph)
21    @res << convert_flow(@am.flow(paragraph.text))
22  end
23
24  def accept_raw raw
25    @res << raw.parts.join
26  end
27
28  def accept_verbatim(verbatim)
29    @res << verbatim.text.gsub(/^(\S)/, '  \1')
30  end
31
32  def accept_list_start(list)
33    @list << case list.type
34             when :BULLET then
35               '*'
36             when :NUMBER then
37               '1'
38             else
39               list.type
40             end
41  end
42
43  def accept_list_end(list)
44    @list.pop
45  end
46
47  def accept_list_item_start(list_item)
48    @res << "#{' ' * (@list.size - 1)}#{@list.last}: "
49  end
50
51  def accept_list_item_end(list_item)
52  end
53
54  def accept_blank_line(blank_line)
55    @res << "\n"
56  end
57
58  def accept_heading(heading)
59    @res << "#{'=' * heading.level} #{heading.text}"
60  end
61
62  def accept_rule(rule)
63    @res << '-' * rule.weight
64  end
65
66  # :startdoc:
67
68end
69
70