diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-01-21 17:44:59 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-01-21 17:45:12 +0000 |
| commit | ac8a3c933a70c2d9aa179216f9ccfd2373c39c1b (patch) | |
| tree | c3cb3313b7e998484b90f1d7770dddb57d399a63 /mammoth/docx/notes_xml.py | |
| parent | 7b4c39650f2ebb0458f6f06375ab682fbc32f90e (diff) | |
Rename modules from footnotes to notes
Diffstat (limited to 'mammoth/docx/notes_xml.py')
| -rw-r--r-- | mammoth/docx/notes_xml.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/mammoth/docx/notes_xml.py b/mammoth/docx/notes_xml.py new file mode 100644 index 0000000..c477553 --- /dev/null +++ b/mammoth/docx/notes_xml.py @@ -0,0 +1,29 @@ +from .. import lists + + +def create_reader(note_type): + def read_notes_xml_element(element): + note_elements = lists.filter( + _is_note_element, + element.find_children("w:" + note_type), + ) + return lists.map(_read_note_element, note_elements) + + + def _is_note_element(element): + return element.attributes.get("w:type") not in ["continuationSeparator", "separator"] + + + def _read_note_element(element): + return NoteElement(note_type, element.attributes["w:id"], element.children) + + return read_notes_xml_element + +class NoteElement(object): + def __init__(self, note_type, id, body): + self.note_type = note_type + self.id = id + self.body = body + + +read_footnotes_xml_element = create_reader("footnote") |
