diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-01-07 22:45:25 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-01-07 22:45:25 +0000 |
| commit | 77b597fc382bc7674f1e4365825aba70814577f4 (patch) | |
| tree | 4b96782b1692a92cce36bb9922cf6973bb89a43e /mammoth/__init__.py | |
| parent | 14a63947d2b6a95eb0505f4e3549f6972cab2d6e (diff) | |
Read default style map once
Diffstat (limited to 'mammoth/__init__.py')
| -rw-r--r-- | mammoth/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/mammoth/__init__.py b/mammoth/__init__.py index 3c726d6..84849ce 100644 --- a/mammoth/__init__.py +++ b/mammoth/__init__.py @@ -4,10 +4,16 @@ from . import docx, conversion, style_reader, lists def convert_to_html(fileobj, style_map=None, convert_image=None): if style_map is None: - style_map = _default_styles + style_map = _default_style_map + else: + style_map = _read_style_map(style_map) return docx.read(fileobj).bind(lambda document: - conversion.convert_document_element_to_html(document, styles=_read_style_map(style_map), convert_image=convert_image) + conversion.convert_document_element_to_html( + document, + styles=style_map, + convert_image=convert_image, + ) ) @@ -17,7 +23,7 @@ def _read_style_map(style_text): -_default_styles = """ +_default_style_map = _read_style_map(""" p.Heading1 => h1:fresh p.Heading2 => h2:fresh p.Heading3 => h3:fresh @@ -32,4 +38,4 @@ 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 -""" +""") |
