Class: RDoc::Markup::ToJoinedParagraph
- Defined in:
- lib/rdoc/markup/to_joined_paragraph.rb
Overview
Joins the parts of an RDoc::Markup::Paragraph into a single String.
This allows for easier maintenance and testing of Markdown support.
This formatter only works on Paragraph instances. Attempting to process other markup syntax items will not work.
Instance Method Summary collapse
-
#accept_paragraph(paragraph) ⇒ Object
Converts the parts of
paragraph
to a single entry. -
#end_accepting ⇒ Object
:nodoc:.
-
#initialize ⇒ ToJoinedParagraph
constructor
:nodoc:.
-
#start_accepting ⇒ Object
:nodoc:.
Methods inherited from Formatter
#accept_document, #add_special_RDOCLINK, #add_special_TIDYLINK, #add_tag, #annotate, #convert, #convert_flow, #convert_special, #convert_string, gen_relative_url, #ignore, #in_tt?, #off_tags, #on_tags, #parse_url, #tt?
Constructor Details
#initialize ⇒ ToJoinedParagraph
:nodoc:
11 12 13 |
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 11 def initialize # :nodoc: super nil end |
Instance Method Details
#accept_paragraph(paragraph) ⇒ Object
Converts the parts of paragraph
to a single entry.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 24 def accept_paragraph paragraph parts = [] string = false paragraph.parts.each do |part| if String === part then if string then string << part else parts << part string = part end else parts << part string = false end end parts = parts.map do |part| if String === part then part.rstrip else part end end # TODO use Enumerable#chunk when Ruby 1.8 support is dropped #parts = paragraph.parts.chunk do |part| # String === part #end.map do |string, chunk| # string ? chunk.join.rstrip : chunk #end.flatten paragraph.parts.replace parts end |
#end_accepting ⇒ Object
:nodoc:
18 19 |
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 18 def end_accepting # :nodoc: end |
#start_accepting ⇒ Object
:nodoc:
15 16 |
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 15 def start_accepting # :nodoc: end |