aboutsummaryrefslogtreecommitdiff
path: root/mammoth/styles/parser/__init__.py
blob: 2266467eb7db5fbd7b4ee14539ce1e01b3bd00ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from .errors import LineParseError
from .style_mapping_parser import parse_style_mapping
from .tokeniser import tokenise
from .token_iterator import TokenIterator
from ... import results


def read_style_mapping(string):
    try:
        tokens = tokenise(string)
        return results.success(parse_style_mapping(TokenIterator(tokens)))
    except LineParseError:
        warning = "Did not understand this style mapping, so ignored it: " + string
        return results.Result(None, [results.warning(warning)])