| Class | RI::AttributeFormatter |
| In: |
ri/ri_formatter.rb
|
| Parent: | TextFormatter |
Handle text with attributes. We‘re a base class: there are different presentation classes (one, for example, uses overstrikes to handle bold and underlining, while another using ANSI escape sequences
| BOLD | = | 1 |
| ITALIC | = | 2 |
| CODE | = | 4 |
| ATTR_MAP | = | { "b" => BOLD, "code" => CODE, "em" => ITALIC, "i" => ITALIC, "tt" => CODE |
overrides base class. Looks for … etc sequences and generates an array of AttrChars. This array is then used as the basis for the split
# File ri/ri_formatter.rb, line 305
305: def wrap(txt, prefix=@indent, linelen=@width)
306: return unless txt && !txt.empty?
307:
308: txt = add_attributes_to(txt)
309: next_prefix = prefix.tr("^ ", " ")
310: linelen -= prefix.size
311:
312: line = []
313:
314: until txt.empty?
315: word = txt.next_word
316: if word.size + line.size > linelen
317: write_attribute_text(prefix, line)
318: prefix = next_prefix
319: line = []
320: end
321: line.concat(word)
322: end
323:
324: write_attribute_text(prefix, line) if line.length > 0
325: end
again, overridden
# File ri/ri_formatter.rb, line 341
341: def bold_print(txt)
342: print txt
343: end