Class: Minidown::IndentCodeElement

Inherits:
Element
  • Object
show all
Defined in:
lib/minidown/elements/indent_code_element.rb

Instance Attribute Summary

Attributes inherited from Element

#children, #content, #doc, #nodes

Instance Method Summary collapse

Methods inherited from Element

#blank?, #raw_content, #raw_content=, #to_html, #unparsed_lines

Methods included from HtmlHelper

#br_tag, #build_tag

Constructor Details

#initialize(*_) ⇒ IndentCodeElement

Returns a new instance of IndentCodeElement.



3
4
5
6
# File 'lib/minidown/elements/indent_code_element.rb', line 3

def initialize *_
  super
  @lines = [content]
end

Instance Method Details

#parseObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/minidown/elements/indent_code_element.rb', line 8

def parse
  while line = unparsed_lines.shift
    case line
    when Utils::Regexp[:indent_code]
      @lines << $1
    else
      unparsed_lines.unshift line
      break
    end
  end
  unparsed_lines.unshift '```'
  unparsed_lines.unshift *@lines
  unparsed_lines.unshift '```'
end