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, #annotate, #apply_regexp_handling, #convert, #convert_string, gen_relative_url, #handle_BOLD, #handle_BOLD_WORD, #handle_EM, #handle_EM_WORD, #handle_HARD_BREAK, #handle_PLAIN_TEXT, #handle_REGEXP_HANDLING_TEXT, #handle_STRIKE, #handle_TEXT, #handle_TIDYLINK, #handle_TT, #handle_inline, #ignore, #initialize, #parse_url, #traverse_inline_nodes, #tt?

Constructor Details

This class inherits a constructor from RDoc::Markup::Formatter

Instance Method Details

#accept_paragraph(paragraph) ⇒ Object

Converts the parts of paragraph to a single entry.



20
21
22
23
24
25
26
27
28
# File 'lib/rdoc/markup/to_joined_paragraph.rb', line 20

def accept_paragraph(paragraph)
  parts = paragraph.parts.chunk do |part|
    String === part
  end.flat_map do |string, chunk|
    string ? chunk.join.rstrip : chunk
  end

  paragraph.parts.replace parts
end

#end_acceptingObject

:nodoc:



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

def end_accepting # :nodoc:
end

#start_acceptingObject

:nodoc:



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

def start_accepting # :nodoc:
end