private Method

LineCollection.change_verbatim_blank_lines

If you have:

normal paragraph text.

   this is code

   and more code

You’ll end up with the fragments Paragraph, BlankLine, Verbatim, BlankLine, Verbatim, BlankLine, etc

The BlankLine in the middle of the verbatim chunk needs to be changed to a real verbatim newline, and the two verbatim blocks merged

Source Code

# File rdoc/markup/simple_markup/fragments.rb, line 208
def change_verbatim_blank_lines
  frag_block = nil
  blank_count = 0
  @fragments.each_with_index do |frag, i|
    if frag_block.nil?
      frag_block = frag if Verbatim === frag
    else
      case frag
      when Verbatim
        blank_count.times { frag_block.add_text("\n") }
        blank_count = 0
        frag_block.add_text(frag.txt)
        @fragments[i] = nil    # remove out current fragment
      when BlankLine
        if frag_block
          blank_count += 1
          @fragments[i] = nil
        end
      else
        frag_block = nil
        blank_count = 0
      end
    end
  end
  @fragments.compact!
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.