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) }  ],
  # `text_join` finds `text_special` tokens (for escape sequences)
  # and joins them with the rest of the text
  [ 'text_join',      lambda { |state| RulesCore::TextJoin.text_join(state) }       ],
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParserCore

new Core()




27
28
29
30
31
32
33
34
35
36
# File 'lib/motion-markdown-it/parser_core.rb', line 27

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.




42
43
44
45
46
47
# File 'lib/motion-markdown-it/parser_core.rb', line 42

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