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.
# File lib/rdoc/markup/to_joined_paragraph.rb, line 17
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
# File lib/rdoc/markup/to_joined_paragraph.rb, line 14
def end_accepting
end
# File lib/rdoc/markup/to_joined_paragraph.rb, line 11
def start_accepting
end
/ | Search |
---|---|
? | Show this help |