Method: Eggshell::Processor#add_format_handler
- Defined in:
- lib/eggshell/processor.rb
#add_format_handler(handler, tags) ⇒ Object
TODO:
if opening tag is regex, don’t escape (but make sure it doesn’t contain {^} or {$})
Register inline format handlers with opening and closing tags. Typically, tags can be arbitrarily nested. However, nesting can be shut off completely or selectively by specifying 0 or more tags separated by a space (empty string is completely disabled).
following form: close[, non_nest]]}
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'lib/eggshell/processor.rb', line 536 def add_format_handler(handler, ) return if !.is_a?(Array) .each do |entry| open, close, no_nest = entry no_nest = '' if no_nest.is_a?(TrueClass) @fmt_handlers[open] = [handler, close, no_nest] _trace "add_format_handler: #{open} #{close} (non-nested: #{no_nest.inspect})" end # regenerate splitting pattern going from longest to shortest openers = @fmt_handlers.keys.sort do |a, b| b.length <=> a.length end regex = '' openers.each do |op| regex = "#{regex}|#{Regexp.quote(op)}|#{Regexp.quote(@fmt_handlers[op][1])}" end @fmt_regex = /(\\|'|"#{regex})/ end |