Method: MarkdownIt::Ruler#push

Defined in:
lib/motion-markdown-it/ruler.rb

#push(ruleName, fn, opt = {}) ⇒ Object

  • Ruler.push(ruleName, fn [, options])

    • ruleName (String): name of added rule.

    • fn (Function): rule function.

    • options (Object): rule options (not mandatory).

*

  • Push new rule to the end of chain. See also

  • [[Ruler.before]], [[Ruler.after]].

*

  • ##### Options:

*

    • __alt__ - array with names of “alternate” chains.

*

  • ##### Example

*

  • “‘javascript

  • var md = require(‘markdown-it’)();

*

  • md.core.ruler.push(‘my_rule’, function replace(state)

  • //…

  • );

  • “‘




217
218
219
220
221
222
223
224
225
# File 'lib/motion-markdown-it/ruler.rb', line 217

def push(ruleName, fn, opt = {})
  @__rules__.push({
    name: ruleName,
    enabled: true,
    fn: fn,
    alt: (opt[:alt] ? [''] + opt[:alt] : [''])
  })
  @__cache__ = nil
end