Class: MarkdownFormatter::ASTNode::BlockQuote

Inherits:
Base
  • Object
show all
Defined in:
lib/markdown_formatter/nodes/block_quote.rb

Instance Attribute Summary

Attributes inherited from Base

#node

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from MarkdownFormatter::ASTNode::Base

Instance Method Details

#to_sObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/markdown_formatter/nodes/block_quote.rb', line 4

def to_s
  node[:children].map do |c|
    case c[:type]
      when :blank
        ">"
      when :header
        "> " + Header.new(c).to_s.gsub(/\R/, "\n> ")
      when :ol, :ul
        "> " + List.new(c).to_s.gsub(/\R(?!\z)/, "\n> ")
      when :blockquote
        "> " + BlockQuote.new(c).to_s
      else
        "> " + Paragraph.new(c).to_s.gsub(/\R/, " ")
    end
  end.join("\n").chomp + "\n"
end