aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mammoth/__init__.py16
-rw-r--r--mammoth/raw_text.py12
2 files changed, 15 insertions, 13 deletions
diff --git a/mammoth/__init__.py b/mammoth/__init__.py
index 8ec2400..f67f890 100644
--- a/mammoth/__init__.py
+++ b/mammoth/__init__.py
@@ -1,4 +1,5 @@
-from . import docx, conversion, options, documents, images, underline
+from . import docx, conversion, options, images, underline
+from .raw_text import extract_raw_text_from_element
__all__ = ["convert_to_html", "extract_raw_text", "images", "underline"]
@@ -24,15 +25,4 @@ def convert(fileobj, transform_document=None, id_prefix=None, **kwargs):
def extract_raw_text(fileobj):
- return docx.read(fileobj).map(_extract_raw_text_from_element)
-
-
-def _extract_raw_text_from_element(element):
- if isinstance(element, documents.Text):
- return element.value
- else:
- text = "".join(map(_extract_raw_text_from_element, element.children))
- if isinstance(element, documents.Paragraph):
- return text + "\n\n"
- else:
- return text
+ return docx.read(fileobj).map(extract_raw_text_from_element)
diff --git a/mammoth/raw_text.py b/mammoth/raw_text.py
new file mode 100644
index 0000000..fb39acf
--- /dev/null
+++ b/mammoth/raw_text.py
@@ -0,0 +1,12 @@
+from . import documents
+
+
+def extract_raw_text_from_element(element):
+ if isinstance(element, documents.Text):
+ return element.value
+ else:
+ text = "".join(map(extract_raw_text_from_element, element.children))
+ if isinstance(element, documents.Paragraph):
+ return text + "\n\n"
+ else:
+ return text