Example #1
0
 def compile(self, ast):
     # Merge adjacent subscripts and superscripts.
     return re.sub(r'<(sup|sub)>(.+?)</\1><\1>(.+?)</\1>', r'<\1>\2\3</\1>',
                   DisplayCompiler.compile(self, ast))
Example #2
0
 def compile(self, ast):
     return r'\ce{{{}}}'.format(DisplayCompiler.compile(self, ast))
Example #3
0
 def compile(self, ast):
     return re.sub(r'(\\ :(?:sub|sup):`)([^`]+?)`\\ \1([^`]+?)`\\ ',
                   r'\1\2\3`\\ ',
                   DisplayCompiler.compile(self, ast)
                   ).replace(r'\ \ ', r'\ ').rstrip(r'\ ')
Example #4
0
 def compile(self, ast):
     # Merge adjacent subscripts, superscripts and \mathrms.
     return r'\({}\)'.format(re.sub(
         r'(_|\^|\\mathrm)\{([^{}]+?)\}(?:\{\})?(?:\1\{([^{}]+?)\})+',
         self._replace, DisplayCompiler.compile(self, ast)))