From 214689b8eb45302a0adea8006fb95b58156fb27e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 7 Jan 2014 22:38:49 +0000 Subject: Update documentation to match mammoth.js --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'README.md') 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: -- cgit v1.2.3