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