Class: RDoc::Markup::ToJoinedParagraph

Inherits:
Formatter
  • Object
show all
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

Methods inherited from Formatter

#accept_document, #add_regexp_handling_RDOCLINK, #add_regexp_handling_TIDYLINK, #add_tag, #annotate, #convert, #convert_flow, #convert_regexp_handling, #convert_string, gen_relative_url, #ignore, #in_tt?, #off_tags, #on_tags, #parse_url, #tt?

Constructor Details

#initializeToJoinedParagraph

:nodoc:



12
13
14
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 12

def initialize # :nodoc:
  super nil
end

Instance Method Details

#accept_paragraph(paragraph) ⇒ Object

Converts the parts of paragraph to a single entry.



25
26
27
28
29
30
31
32
33
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 25

def accept_paragraph paragraph
  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_acceptingObject

:nodoc:



19
20
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 19

def end_accepting # :nodoc:
end

#start_acceptingObject

:nodoc:



16
17
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 16

def start_accepting # :nodoc:
end