Class: RDoc::Markup::Verbatim

Inherits:
Raw
  • Object
show all
Defined in:
lib/rdoc/markup/verbatim.rb

Overview

A section of verbatim text

Instance Attribute Summary

Attributes inherited from Raw

#parts

Instance Method Summary collapse

Methods inherited from Raw

#<<, #==, #initialize, #merge, #pretty_print, #push

Constructor Details

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

Instance Method Details

#accept(visitor) ⇒ Object

Calls #accept_verbatim on visitor



9
10
11
# File 'lib/rdoc/markup/verbatim.rb', line 9

def accept visitor
  visitor.accept_verbatim self
end

#normalizeObject

Collapses 3+ newlines into two newlines



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rdoc/markup/verbatim.rb', line 16

def normalize
  parts = []

  newlines = 0

  @parts.each do |part|
    case part
    when /^\s*\n/ then
      newlines += 1
      parts << part if newlines == 1
    else
      newlines = 0
      parts << part
    end
  end

  parts.pop if parts.last =~ /\A\r?\n\z/

  @parts = parts
end

#textObject

The text of the section



40
41
42
# File 'lib/rdoc/markup/verbatim.rb', line 40

def text
  @parts.join
end