| Class | MathML::LaTeX::Scanner |
| In: |
lib/math_ml/latex.rb
|
| Parent: | StringScanner |
| eos? | -> | _eos? |
| check | -> | _check |
| scan | -> | _scan |
# File lib/math_ml/latex.rb, line 110
110: def check_any(remain_space=false)
111: skip_space_and(true){scan_any(remain_space)}
112: end
# File lib/math_ml/latex.rb, line 83
83: def check_block
84: skip_space_and(true){scan_block}
85: end
# File lib/math_ml/latex.rb, line 147
147: def check_option
148: skip_space_and(true){scan_option}
149: end
# File lib/math_ml/latex.rb, line 114
114: def scan_any(remain_space=false)
115: p = pos
116: scan_space
117: r = remain_space ? matched.to_s : ""
118: case
119: when s = scan_block
120: when s = scan_command
121: else
122: unless _scan(/./) || remain_space
123: self.pos = p
124: return nil
125: end
126: s = matched.to_s
127: end
128: r << s
129: end
# File lib/math_ml/latex.rb, line 87
87: def scan_block
88: return nil unless scan(/\{/)
89: block = "{"
90: bpos = pos-1
91: nest = 1
92: while _scan(/(#{MBEC}*?)([\{\}])/)
93: block << matched
94: case self[2]
95: when "{"
96: nest+=1
97: when "}"
98: nest-=1
99: break if nest==0
100: end
101: end
102: if nest>0
103: self.pos = bpos
104: raise BlockNotClosed
105: end
106: self.pos = bpos
107: _scan(/\A\{(#{Regexp.escape(block[RE::BLOCK, 1].to_s)})\}/)
108: end
# File lib/math_ml/latex.rb, line 131
131: def scan_option
132: return nil unless scan(/\[/)
133: opt = "["
134: p = pos-1
135: until (s=scan_any(true)) =~ /\A#{RE::SPACE}*\]\z/
136: opt << s
137: if eos?
138: self.pos = p
139: raise OptionNotClosed
140: end
141: end
142: opt << s
143: self.pos = p
144: _scan(/\A\[(#{Regexp.escape(opt[RE::OPTION, 1].to_s)})\]/)
145: end