class RDoc::Markup::ToJoinedParagraph

frozen_string_literal: true

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.

Public Instance Methods

accept_paragraph(paragraph) click to toggle source

Converts the parts of paragraph to a single entry.

# 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