Build and append footnote div to end of document.
| 434 | |
| 435 | |
| 436 | class FootnoteTreeprocessor(Treeprocessor): |
| 437 | """ Build and append footnote div to end of document. """ |
| 438 | |
| 439 | def __init__(self, footnotes: FootnoteExtension): |
| 440 | self.footnotes = footnotes |
| 441 | |
| 442 | def run(self, root: etree.Element) -> None: |
| 443 | footnotesDiv = self.footnotes.makeFootnotesDiv(root) |
| 444 | if footnotesDiv is not None: |
| 445 | result = self.footnotes.findFootnotesPlaceholder(root) |
| 446 | if result: |
| 447 | child, parent, isText = result |
| 448 | ind = list(parent).index(child) |
| 449 | if isText: |
| 450 | parent.remove(child) |
| 451 | parent.insert(ind, footnotesDiv) |
| 452 | else: |
| 453 | parent.insert(ind + 1, footnotesDiv) |
| 454 | child.tail = None |
| 455 | else: |
| 456 | root.append(footnotesDiv) |
| 457 | |
| 458 | |
| 459 | class FootnoteReorderingProcessor(Treeprocessor): |