diff options
| author | Michael Williamson <mike@zwobble.org> | 2019-12-16 20:44:17 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2019-12-16 20:44:17 +0000 |
| commit | 96182233ac0ab7b9004ef587068ff780a025c070 (patch) | |
| tree | af8f30d5194386c82b15377550742adbf1b6683d /README.md | |
| parent | 1910ad28d27d5aee78e09669a023eb5cbad6fdfe (diff) | |
Document HTML path for ignore
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 57 |
1 files changed, 33 insertions, 24 deletions
@@ -21,11 +21,11 @@ The following features are currently supported: * Customisable mapping from your own docx styles to HTML. For instance, you could convert `WarningHeading` to `h1.warning` by providing an appropriate style mapping. - + * Tables. The formatting of the table itself, such as borders, is currently ignored, but the formatting of the text is treated the same as in the rest of the document. - + * Footnotes and endnotes. * Images. @@ -65,7 +65,7 @@ The easiest way to try out mammoth is to use the web demo: * [.NET](https://github.com/mwilliamson/dotnet-mammoth). Available [on NuGet](https://www.nuget.org/packages/Mammoth/). - + ## Usage ### CLI @@ -98,7 +98,7 @@ A custom style map can be read from a file using `--style-map`. For instance: mammoth document.docx output.html --style-map=custom-style-map - + Where `custom-style-map` looks something like: p[style-name='Aside Heading'] => div.aside > h2:fresh @@ -326,17 +326,17 @@ Converts the source document to HTML. * `input`: an object describing the source document. On node.js, the following inputs are supported: - + * `{path: path}`, where `path` is the path to the .docx file. * `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file. - + In the browser, the following inputs are supported: - + * `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file. - + * `options` (optional): options for the conversion. May have the following properties: - + * `styleMap`: controls the mapping of Word styles to HTML. If `options.styleMap` is a string, each line is treated as a separate style mapping, @@ -354,18 +354,18 @@ Converts the source document to HTML. the style map passed in `styleMap` is combined with the default style map. To stop using the default style map altogether, set `options.includeDefaultStyleMap` to `false`. - + * `convertImage`: by default, images are converted to `<img>` elements with the source included inline in the `src` attribute. Set this option to an [image converter](#image-converters) to override the default behaviour. - + * `ignoreEmptyParagraphs`: by default, empty paragraphs are ignored. Set this option to `false` to preserve empty paragraphs in the output. - + * `idPrefix`: a string to prepend to any generated IDs, such as those used by bookmarks, footnotes and endnotes. Defaults to an empty string. - + * `transformDocument`: if set, this function is applied to the document read from the docx file before the conversion to HTML. The API for document transforms should be considered unstable. @@ -392,12 +392,12 @@ Each paragraph is followed by two newlines. * `input`: an object describing the source document. On node.js, the following inputs are supported: - + * `{path: path}`, where `path` is the path to the .docx file. * `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file. - + In the browser, the following inputs are supported: - + * `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file. * Returns a promise containing a result. @@ -416,12 +416,12 @@ it will use the embedded style map. * `input`: an object describing the source document. On node.js, the following inputs are supported: - + * `{path: path}`, where `path` is the path to the .docx file. * `{buffer: buffer}`, where `buffer` is a node.js Buffer containing a .docx file. - + In the browser, the following inputs are supported: - + * `{arrayBuffer: arrayBuffer}`, where `arrayBuffer` is an array buffer containing a .docx file. * `styleMap`: the style map to embed. @@ -459,7 +459,7 @@ and has the following properties: * `read([encoding])`: read the image file with the specified encoding. If no encoding is specified, a `Buffer` is returned. - + * `contentType`: the content type of the image, such as `image/png`. `func` should return an object (or a promise of an object) of attributes for the `<img>` element. @@ -501,11 +501,11 @@ function transformElement(element) { var children = _.map(element.children, transformElement); element = {...element, children: children}; } - + if (element.type === "paragraph") { element = transformParagraph(element); } - + return element; } @@ -798,6 +798,15 @@ div.aside > h2 You can nest elements to any depth. +#### Ignoring document elements + +Use `!` to ignore a document element. +For instance, to ignore any paragraph with the style `Comment`: + +``` +p[style-name='Comment'] => ! +``` + ## Upgrading to later versions ### 1.0.0 @@ -851,12 +860,12 @@ Thanks to the following people for their contributions to Mammoth: * [Craig Leinoff](https://github.com/Offlein): * Document transforms - + * [John McLear](https://github.com/JohnMcLear): * Underline support -* [Chris Price](https://github.com/studiochris): +* [Chris Price](https://github.com/studiochris): * node.js `Buffer` support * UTF8 BOM handling |
