Skip to content

Commit aaa1655

Browse files
committed
#6 Footnotes support only one paragraph
Footnotes support only one paragraph while they could be made out of multiple paragraphs. This is exactly like it is for endnotes. Just parse all the paragraphs and store them together.
1 parent 5926ea4 commit aaa1655

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

ooxml/parse.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,19 +521,20 @@ def parse_footnotes(document, xmlcontent):
521521
Footnotes are defined in file 'footnotes.xml'
522522
"""
523523

524-
styles = etree.fromstring(xmlcontent)
524+
footnotes = etree.fromstring(xmlcontent)
525525
document.footnotes = {}
526526

527-
for style in styles.xpath('.//w:footnote', namespaces=NAMESPACES):
528-
_type = style.attrib.get(_name('{{{w}}}type'), None)
527+
for footnote in footnotes.xpath('.//w:footnote', namespaces=NAMESPACES):
528+
_type = footnote.attrib.get(_name('{{{w}}}type'), None)
529529

530530
# don't know what to do with these now
531531
if _type in ['separator', 'continuationSeparator', 'continuationNotice']:
532532
continue
533533

534-
p = parse_paragraph(document, style.find(_name('{{{w}}}p')))
534+
# p = parse_paragraph(document, footnote.find(_name('{{{w}}}p')))
535+
paragraphs = [parse_paragraph(document, para) for para in footnote.xpath('.//w:p', namespaces=NAMESPACES)]
535536

536-
document.footnotes[style.attrib[_name('{{{w}}}id')]] = p
537+
document.footnotes[footnote.attrib[_name('{{{w}}}id')]] = paragraphs
537538

538539

539540
def parse_endnotes(document, xmlcontent):

ooxml/serialize.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,6 @@ def serialize_symbol(ctx, document, el, root):
675675
def serialize_footnote(ctx, document, el, root):
676676
"Serializes footnotes."
677677

678-
p_foot = document.footnotes[el.rid]
679-
680-
p = etree.Element('p')
681-
foot_doc = serialize_paragraph(ctx, document, p_foot, p)
682-
# must put content of the footter somewhere
683678
footnote_num = el.rid
684679

685680
if el.rid not in ctx.footnote_list:

0 commit comments

Comments
 (0)