Module: HamdownCore::Utils
- Defined in:
- lib/hamdown_core/utils.rb
Class Method Summary collapse
Class Method Details
.balance(scanner, start, finish, depth = 1) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hamdown_core/utils.rb', line 6 def balance(scanner, start, finish, depth = 1) re = /(#{Regexp.escape(start)}|#{Regexp.escape(finish)})/ while depth > 0 && scanner.scan_until(re) if scanner.matched == start depth += 1 else depth -= 1 end end depth end |