aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/comments_xml.py
blob: 9a92552272e7a78838febafcf11d5ed661cf4f7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from .. import lists
from .. import documents
from .. import results


def create_comments_reader(body_reader):
    def read_comments_xml_element(element):
        comment_elements = element.find_children("w:comment")
        return results.combine(lists.map(_read_comment_element, comment_elements))


    def _read_comment_element(element):
        return body_reader.read_all(element.children).map(lambda body:
            documents.comment(
                comment_id=element.attributes["w:id"],
                body=body
            ))

    return read_comments_xml_element