Class: MarkdownIt::RulesBlock::Code

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-markdown-it/rules_block/code.rb

Class Method Summary collapse

Class Method Details

.code(state, startLine, endLine, silent = true) ⇒ Object




8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/motion-markdown-it/rules_block/code.rb', line 8

def self.code(state, startLine, endLine, silent = true)
  return false if (state.sCount[startLine] - state.blkIndent < 4)

  last = nextLine = startLine + 1
  while nextLine < endLine
    if state.isEmpty(nextLine)
      nextLine += 1
      next
    end

    if (state.sCount[nextLine] - state.blkIndent >= 4)
      nextLine += 1
      last = nextLine
      next
    end
    break
  end

  state.line    = last

  token         = state.push('code_block', 'code', 0)
  token.content = state.getLines(startLine, last, 4 + state.blkIndent, true)
  token.map     = [ startLine, state.line ]
  return true
end