Class: MarkdownIt::ParserCore

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

Constant Summary collapse

RULES =
[
  [ 'normalize',      lambda { |state| RulesCore::Normalize.normalize(state) }         ],
  [ 'block',          lambda { |state| RulesCore::Block.block(state) }              ],
  [ 'inline',         lambda { |state| RulesCore::Inline.inline(state) }            ],
  [ 'linkify',        lambda { |state| RulesCore::Linkify.linkify(state) }          ],
  [ 'replacements',   lambda { |state| RulesCore::Replacements.replace(state) }     ],
  [ 'smartquotes',    lambda { |state| RulesCore::Smartquotes.smartquotes(state) }  ],
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParserCore

new Core()




24
25
26
27
28
29
30
31
32
33
# File 'lib/motion-markdown-it/parser_core.rb', line 24

def initialize
  # Core#ruler -> Ruler
  #
  # [[Ruler]] instance. Keep configuration of core rules.
  @ruler = Ruler.new

  RULES.each do |rule|
    @ruler.push(rule[0], rule[1])
  end
end

Instance Attribute Details

#rulerObject

Returns the value of attribute ruler.



10
11
12
# File 'lib/motion-markdown-it/parser_core.rb', line 10

def ruler
  @ruler
end

Instance Method Details

#process(state) ⇒ Object

Core.process(state)

Executes core chain rules.




39
40
41
42
43
44
# File 'lib/motion-markdown-it/parser_core.rb', line 39

def process(state)
  rules = @ruler.getRules('')
  rules.each do |rule|
    rule.call(state)
  end
end