diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-07-06 18:01:40 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-07-06 18:01:40 +0100 |
| commit | 8badf20e2107982f076ef9e90dc84820e96a77ff (patch) | |
| tree | f98114adf03445d72c94673a70093c0d20f2c1c7 | |
| parent | 040607b07c6ea0d4788f1536d01a0de36039cc88 (diff) | |
Document extractRawText
| -rw-r--r-- | README.md | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -109,6 +109,19 @@ mammoth.convertToHtml({path: "path/to/document.docx"}) Note that `mammoth.convertToHtml` returns a [promise](http://promises-aplus.github.io/promises-spec/). +You can also extract the raw text of the document by using `mammoth.extractRawText`. +This will ignore all formatting in the document. +Each paragraph is followed by two newlines. + +```javascript +mammoth.extractRawText({path: "path/to/document.docx"}) + .then(function(result){ + var text = result.value; // The raw text + var messages = result.messages; + }) + .done(); +``` + #### Custom style map By default, @@ -223,6 +236,25 @@ Converts the source document to HTML. * `messages`: any messages, such as errors and warnings, generated during the conversion +#### `mammoth.extractRawText(input)` + +Extract the raw text of the document. +This will ignore all formatting in the document. +Each paragraph is followed by two newlines. + +* `input`: an object describing the source document. + While running on node.js, + to read the file found at `path`, pass in `{path: path}`. + While running in the browser, + to read the file stored in an array buffer, pass in `{arrayBuffer: arrayBuffer}`. + +* Returns a promise containing a result. + This result has the following properties: + + * `value`: the raw text + + * `messages`: any messages + #### Messages Each message has the following properties: |
