Method: Mathemagical::LaTeX::Scanner#scan_block
- Defined in:
- lib/mathemagical/latex.rb
#scan_block ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/mathemagical/latex.rb', line 87 def scan_block return nil unless scan(/\{/) block = "{" bpos = pos-1 nest = 1 while _scan(/(#{MBEC}*?)([\{\}])/) block << matched case self[2] when "{" nest+=1 when "}" nest-=1 break if nest==0 end end if nest>0 self.pos = bpos raise BlockNotClosed end self.pos = bpos _scan(/\A\{(#{Regexp.escape(block[RE::BLOCK, 1].to_s)})\}/) end |