Skip to content

Commit

Permalink
Document HTML path for ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilliamson committed Dec 16, 2019
1 parent 1910ad2 commit 9618223
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9618223

Please sign in to comment.