aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-01-07 22:38:49 +0000
committerMichael Williamson <mike@zwobble.org>2014-01-07 22:40:16 +0000
commit214689b8eb45302a0adea8006fb95b58156fb27e (patch)
tree553866b300adafe55aca6830017991fe244fe4d6
parentb10f31d1ca985f548b96f3af8818a97ab8112c2b (diff)
Update documentation to match mammoth.js
-rw-r--r--README.md13
1 files changed, 9 insertions, 4 deletions
diff --git a/README.md b/README.md
index aadd065..bcebc0b 100644
--- a/README.md
+++ b/README.md
@@ -69,20 +69,25 @@ By default,
Mammoth maps some common .docx styles to HTML elements.
For instance,
a paragraph with the style `Heading1` is converted to a `h1` element.
-You can pass in custom styles using the `styles` argument:
+You can pass in a custom map for styles by passing an options object with a `styleMap` property as a second argument to `convertToHtml`.
+A description of the syntax for styles can be found in the section "Writing styles".
+For instance, if paragraphs with the style `SectionTitle` should be converted to `h1` elements,
+and paragraphs with the style `SubSectionTitle` should be converted to `h2` elements:
```python
import mammoth
styles = """
-p.AsideHeading => div.aside > h2:fresh
-p.AsideText => div.aside > p:fresh
+p.SectionTitle => h1:fresh
+p.SubSectionTitle => h2:fresh
"""
with open("document.docx", "rb") as docx_file:
- result = mammoth.convert_to_html(docx_file, styles)
+ result = mammoth.convert_to_html(docx_file, styles=styles)
```
+User-defined style mappings are used in preference to the default style mappings.
+
## Writing styles
A style has two parts: