Class: RuVim::Lang::Markdown::FenceState

Inherits:
Object
  • Object
show all
Defined in:
lib/ruvim/lang/markdown.rb

Overview

--- FenceState: tracks code fence open/close across lines ---

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFenceState

Returns a new instance of FenceState.



38
39
40
41
# File 'lib/ruvim/lang/markdown.rb', line 38

def initialize
  @in_code_block = false
  @fence_marker = nil
end

Instance Attribute Details

#fence_markerObject (readonly)

Returns the value of attribute fence_marker.



36
37
38
# File 'lib/ruvim/lang/markdown.rb', line 36

def fence_marker
  @fence_marker
end

#in_code_blockObject (readonly)

Returns the value of attribute in_code_block.



36
37
38
# File 'lib/ruvim/lang/markdown.rb', line 36

def in_code_block
  @in_code_block
end

Instance Method Details

#scan_line(line) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruvim/lang/markdown.rb', line 43

def scan_line(line)
  stripped = line.to_s.strip
  if @in_code_block
    if fence_close?(stripped)
      @in_code_block = false
      @fence_marker = nil
    end
  else
    marker = fence_open(stripped)
    if marker
      @in_code_block = true
      @fence_marker = marker
    end
  end
end