From 50a1a16aae9fa8809fb6d9e531e8483c8bb05b25 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 6 Jul 2014 18:05:59 +0100 Subject: Document extract_raw_text --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index c09aea9..ff51784 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,18 @@ with open("document.docx", "rb") as docx_file: messages = result.messages # Any messages, such as warnings during conversion ``` +You can also extract the raw text of the document by using `mammoth.extract_raw_text`. +This will ignore all formatting in the document. +Each paragraph is followed by two newlines. + +```python +with open("document.docx", "rb") as docx_file: + result = mammoth.extract_raw_text(docx_file) + text = result.value # The raw text + messages = result.messages # Any messages +``` + + #### Custom style map By default, @@ -139,6 +151,21 @@ Converts the source document to HTML. * `messages`: any messages, such as errors and warnings, generated during the conversion +#### `mammoth.extract_raw_text(fileobj)` + +Extract the raw text of the document. +This will ignore all formatting in the document. +Each paragraph is followed by two newlines. + +* `fileobj`: a file-like object containing the source document. + Files should be opened in binary mode. + +* Returns a result with the following properties: + + * `value`: the raw text + + * `messages`: any messages, such as errors and warnings + #### Messages Each message has the following properties: -- cgit v1.2.3