MCPcopy Create free account
hub / github.com/ActiveState/code / candidates

Method candidates

recipes/Python/252124_LaTeX_codec/recipe-252124.py:170–193  ·  view source on GitHub ↗

Generate pairs delta,c where c is a token or tuple of tokens from tex (after deleting extraneous brackets starting at pos) and delta is the length of the tokens prior to bracket deletion.

(self,offset)

Source from the content-addressed store, hash-verified

168 return self[-1]
169
170 def candidates(self,offset):
171 """Generate pairs delta,c where c is a token or tuple of tokens from tex
172 (after deleting extraneous brackets starting at pos) and delta
173 is the length of the tokens prior to bracket deletion.
174 """
175 t = self[offset]
176 if t in _blacklist:
177 return
178 elif t == '{':
179 for delta,c in self.candidates(offset+1):
180 if self[offset+delta+1] == '}':
181 yield delta+2,c
182 elif t == '\\mbox':
183 for delta,c in self.candidates(offset+1):
184 yield delta+1,c
185 elif t == '$' and self[offset+2] == '$':
186 yield 3, (t,self[offset+1],t)
187 else:
188 q = self[offset+1]
189 if q == '{' and self[offset+3] == '}':
190 yield 4, (t,self[offset+2])
191 elif q:
192 yield 2, (t,q)
193 yield 1, t
194
195latex_equivalents = {
196 0x0009: ' ',

Callers 1

chunkMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected