2010-04-01 03:45:16 -04:00
|
|
|
##
|
|
|
|
# A section of verbatim text
|
|
|
|
|
2010-04-26 23:45:22 -04:00
|
|
|
class RDoc::Markup::Verbatim < RDoc::Markup::Raw
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
##
|
|
|
|
# Calls #accept_verbatim on +visitor+
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
def accept visitor
|
|
|
|
visitor.accept_verbatim self
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Collapses 3+ newlines into two newlines
|
|
|
|
|
|
|
|
def normalize
|
|
|
|
parts = []
|
|
|
|
|
|
|
|
newlines = 0
|
|
|
|
|
|
|
|
@parts.each do |part|
|
|
|
|
case part
|
2010-12-19 22:22:49 -05:00
|
|
|
when /^\s*\n/ then
|
2010-04-01 03:45:16 -04:00
|
|
|
newlines += 1
|
2010-12-19 22:22:49 -05:00
|
|
|
parts << part if newlines == 1
|
2010-04-01 03:45:16 -04:00
|
|
|
else
|
|
|
|
newlines = 0
|
|
|
|
parts << part
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
parts.pop if parts.last =~ /\A\r?\n\z/
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
@parts = parts
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The text of the section
|
|
|
|
|
|
|
|
def text
|
|
|
|
@parts.join
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|