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

Method chunk

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

Grab another set of input tokens and convert them to an output string.

(self)

Source from the content-addressed store, hash-verified

151 return nextoutput
152
153 def chunk(self):
154 """Grab another set of input tokens and convert them to an output string."""
155 for delta,c in self.candidates(0):
156 if c in _l2u:
157 self.pos += delta
158 return unichr(_l2u[c])
159 elif len(c) == 2 and c[1] == 'i' and (c[0],'\\i') in _l2u:
160 self.pos += delta # correct failure to undot i
161 return unichr(_l2u[(c[0],'\\i')])
162 elif len(c) == 1 and c[0].startswith('\\char') and c[0][5:].isdigit():
163 self.pos += delta
164 return unichr(int(c[0][5:]))
165
166 # nothing matches, just pass through token as-is
167 self.pos += 1
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

Callers 1

nextMethod · 0.95

Calls 2

candidatesMethod · 0.95
startswithMethod · 0.80

Tested by

no test coverage detected