How to use the latex2mathml.exceptions.EmptyGroupError function in latex2mathml

To help you get started, weโ€™ve selected a few latex2mathml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github roniemartinez / latex2mathml / latex2mathml / aggregator.py View on Github external
tokens: Iterator,
    opening: str = OPENING_BRACES,
    closing: str = CLOSING_BRACES,
    delimiter: Union[str, None] = None,
) -> list:
    g = []  # type: List[Any]
    if delimiter:
        g.append(delimiter)
        g.append(next(tokens))
    while True:
        try:
            token = next(tokens)
            if token == closing and not delimiter:
                if len(g):
                    break
                raise EmptyGroupError
            elif token == opening:
                try:
                    g.append(group(tokens))
                except EmptyGroupError:
                    g += [[]]
            elif token == LEFT:
                g.append(group(tokens, delimiter=token))
            elif token == RIGHT:
                g.append(token)
                g.append(next(tokens))
                break
            else:
                g.append(token)
        except StopIteration:
            break
    if delimiter:
github tsengwoody / Access8Math / addon / globalPlugins / MathMlReader / latex2mathml / aggregator.py View on Github external
aggregated += [previous, token]
            return
        try:
            next_token = next_item_or_group(tokens)
            if len(aggregated) >= 2:
                if aggregated[-2] == '_' and token == '^':
                    aggregated[-2] = '_^'
                    aggregated += [previous, next_token]
                elif aggregated[-2] == '^' and token == '_':
                    aggregated[-2] = '_^'
                    aggregated += [next_token, previous]
                else:
                    aggregated += [token, previous, next_token]
            else:
                aggregated += [token, previous, next_token]
        except EmptyGroupError:
            aggregated += [previous, token, '{', '}']
        except StopIteration:
            return
    except IndexError:
        aggregated.append(token)