Class: PointBlank::Parsing::LineScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/mmmd/blankshell.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, doc) ⇒ LineScanner

Returns a new instance of LineScanner.



198
199
200
201
202
203
204
# File 'lib/mmmd/blankshell.rb', line 198

def initialize(text, doc)
  @text = text
  @document = doc
  @stack = [@document]
  @depth = 0
  @topdepth = 0
end

Instance Method Details

#scanObject

Scan document and return scanned structure



207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/mmmd/blankshell.rb', line 207

def scan
  @text.each_line do |line|
    # Consume markers from lines to keep the levels open
    line = consume_markers(line)
    # DO NOT RHEDEEM line if it's empty
    line = line&.strip&.empty? ? nil : line
    # Open up a new block on the line out of all allowed child types
    while line && (status, line = try_open(line)) && status; end
  end
  close_up(0)
  @stack.first
end