2017-11-27 05:45:24 -05:00
|
|
|
# frozen_string_literal: true
|
2012-11-26 23:28:14 -05:00
|
|
|
##
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
|
|
|
|
|
|
|
|
def initialize # :nodoc:
|
|
|
|
super nil
|
|
|
|
end
|
|
|
|
|
2012-12-07 00:22:50 -05:00
|
|
|
def start_accepting # :nodoc:
|
2012-11-26 23:28:14 -05:00
|
|
|
end
|
|
|
|
|
2012-12-07 00:22:50 -05:00
|
|
|
def end_accepting # :nodoc:
|
2012-11-26 23:28:14 -05:00
|
|
|
end
|
|
|
|
|
2012-12-07 00:22:50 -05:00
|
|
|
##
|
|
|
|
# Converts the parts of +paragraph+ to a single entry.
|
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
def accept_paragraph paragraph
|
2017-11-27 05:45:24 -05:00
|
|
|
parts = paragraph.parts.chunk do |part|
|
|
|
|
String === part
|
|
|
|
end.map do |string, chunk|
|
|
|
|
string ? chunk.join.rstrip : chunk
|
|
|
|
end.flatten
|
2012-11-26 23:28:14 -05:00
|
|
|
|
|
|
|
paragraph.parts.replace parts
|
|
|
|
end
|
|
|
|
|
|
|
|
alias accept_block_quote ignore
|
|
|
|
alias accept_heading ignore
|
|
|
|
alias accept_list_end ignore
|
|
|
|
alias accept_list_item_end ignore
|
|
|
|
alias accept_list_item_start ignore
|
|
|
|
alias accept_list_start ignore
|
|
|
|
alias accept_raw ignore
|
|
|
|
alias accept_rule ignore
|
|
|
|
alias accept_verbatim ignore
|
|
|
|
|
|
|
|
end
|
|
|
|
|