From 189b6180fc032c95e49023879fcf328795b45bd3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 7 Jan 2014 22:50:38 +0000 Subject: Read options in separate module --- mammoth/options.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 mammoth/options.py (limited to 'mammoth/options.py') diff --git a/mammoth/options.py b/mammoth/options.py new file mode 100644 index 0000000..4e4d5f1 --- /dev/null +++ b/mammoth/options.py @@ -0,0 +1,36 @@ +from . import style_reader, lists + + +def read_options(options): + if options.get("style_map") is None: + style_map = _default_style_map + else: + style_map = _read_style_map(style_map) + + options["style_map"] = style_map + return options + + +def _read_style_map(style_text): + lines = filter(None, map(lambda line: line.strip(), style_text.split("\n"))) + return lists.map(style_reader.read_style, lines) + + + +_default_style_map = _read_style_map(""" +p.Heading1 => h1:fresh +p.Heading2 => h2:fresh +p.Heading3 => h3:fresh +p.Heading4 => h4:fresh +p:unordered-list(1) => ul > li:fresh +p:unordered-list(2) => ul|ol > li > ul > li:fresh +p:unordered-list(3) => ul|ol > li > ul|ol > li > ul > li:fresh +p:unordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh +p:unordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh +p:ordered-list(1) => ol > li:fresh +p:ordered-list(2) => ul|ol > li > ol > li:fresh +p:ordered-list(3) => ul|ol > li > ul|ol > li > ol > li:fresh +p:ordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh +p:ordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh +""") + -- cgit v1.2.3