def process(self, string, pos):
"""Expand active characters and macros in string.
Raises InputError if it encounters an active character or
macro it doesn't recognize.
"""
self.__data = string
self.__off = 0
self.__pos = pos
# Process macros
while True:
m = tex_cs_re.search(self.__data, self.__off)
if not m:
break
self.__off = m.end()
macro = m.group(1)
nval = self._expand(macro)
if nval is None:
if macro.startswith('\\'):
pos.raise_error('unknown macro `{}\''.format(macro))
pos.raise_error(
'unknown special character `{}\''.format(macro))
self.__data = self.__data[:m.start()] + nval + \
self.__data[self.__off:]
self.__off = m.start() + len(nval)
return self.__data
评论列表
文章目录