| Class | RDoc::Markup::ToFlow |
| In: |
markup/to_flow.rb
|
| Parent: | RDoc::Markup::Formatter |
# File markup/to_flow.rb, line 113
113: def accept_blank_line(am, fragment)
114: # @res << annotate("<p />") << "\n"
115: end
# File markup/to_flow.rb, line 117
117: def accept_heading(am, fragment)
118: @res << Flow::H.new(fragment.head_level, convert_flow(am.flow(fragment.txt)))
119: end
# File markup/to_flow.rb, line 105
105: def accept_list_end(am, fragment)
106: @res = @list_stack.pop
107: end
# File markup/to_flow.rb, line 109
109: def accept_list_item(am, fragment)
110: @res << Flow::LI.new(fragment.param, convert_flow(am.flow(fragment.txt)))
111: end
# File markup/to_flow.rb, line 98
98: def accept_list_start(am, fragment)
99: @list_stack.push(@res)
100: list = Flow::LIST.new(fragment.type)
101: @res << list
102: @res = list
103: end
# File markup/to_flow.rb, line 84
84: def accept_paragraph(am, fragment)
85: @res << Flow::P.new((convert_flow(am.flow(fragment.txt))))
86: end
# File markup/to_flow.rb, line 92
92: def accept_rule(am, fragment)
93: size = fragment.param
94: size = 10 if size > 10
95: @res << Flow::RULE.new(size)
96: end
# File markup/to_flow.rb, line 88
88: def accept_verbatim(am, fragment)
89: @res << Flow::VERB.new((convert_flow(am.flow(fragment.txt))))
90: end
Given an HTML tag, decorate it with class information and the like if required. This is a no-op in the base class, but is overridden in HTML output classes that implement style sheets
# File markup/to_flow.rb, line 68
68: def annotate(tag)
69: tag
70: end
# File markup/to_flow.rb, line 145
145: def convert_flow(flow)
146: res = ""
147: flow.each do |item|
148: case item
149: when String
150: res << convert_string(item)
151: when AttrChanger
152: off_tags(res, item)
153: on_tags(res, item)
154: when Special
155: res << convert_special(item)
156: else
157: raise "Unknown flow element: #{item.inspect}"
158: end
159: end
160: res
161: end
# File markup/to_flow.rb, line 167
167: def convert_special(special)
168: handled = false
169: Attribute.each_name_of(special.type) do |name|
170: method_name = "handle_special_#{name}"
171: if self.respond_to? method_name
172: special.text = send(method_name, special)
173: handled = true
174: end
175: end
176:
177: raise "Unhandled special: #{special}" unless handled
178:
179: special.text
180: end
Set up the standard mapping of attributes to HTML tags
# File markup/to_flow.rb, line 47
47: def init_tags
48: @attr_tags = [
49: InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
50: InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
51: InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:EM), "<em>", "</em>"),
52: ]
53: end
# File markup/to_flow.rb, line 134
134: def off_tags(res, item)
135: attr_mask = item.turn_off
136: return if attr_mask.zero?
137:
138: @attr_tags.reverse_each do |tag|
139: if attr_mask & tag.bit != 0
140: res << annotate(tag.off)
141: end
142: end
143: end
# File markup/to_flow.rb, line 123
123: def on_tags(res, item)
124: attr_mask = item.turn_on
125: return if attr_mask.zero?
126:
127: @attr_tags.each do |tag|
128: if attr_mask & tag.bit != 0
129: res << annotate(tag.on)
130: end
131: end
132: end