Class: RDocF95::RI::AttributeFormatter
- Defined in:
- lib/rdoc-f95/ri/formatter.rb
Overview
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.
Direct Known Subclasses
Defined Under Namespace
Classes: AttrChar, AttributeString
Constant Summary collapse
- BOLD =
1
- ITALIC =
2
- CODE =
4
- ATTR_MAP =
{ "b" => BOLD, "code" => CODE, "em" => ITALIC, "i" => ITALIC, "tt" => CODE }
Constants inherited from Formatter
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary collapse
-
#wrap(txt, prefix = @indent, linelen = @width) ⇒ Object
Overrides base class.
Methods inherited from Formatter
#blankline, #break_to_newline, #conv_html, #conv_markup, #display_flow, #display_flow_item, #display_heading, #display_list, #display_verbatim_flow_item, #draw_line, for, #initialize, list, #raw_print_line, #strip_attributes
Constructor Details
This class inherits a constructor from RDocF95::RI::Formatter
Instance Method Details
#wrap(txt, prefix = @indent, linelen = @width) ⇒ Object
Overrides base class. Looks for ...
etc sequences and generates an array of AttrChars. This array is then used as the basis for the split.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/rdoc-f95/ri/formatter.rb', line 276 def wrap(txt, prefix=@indent, linelen=@width) return unless txt && !txt.empty? txt = add_attributes_to(txt) next_prefix = prefix.tr("^ ", " ") linelen -= prefix.size line = [] until txt.empty? word = txt.next_word if word.size + line.size > linelen write_attribute_text(prefix, line) prefix = next_prefix line = [] end line.concat(word) end write_attribute_text(prefix, line) if line.length > 0 end |