summaryrefslogtreecommitdiff
path: root/sandbox/presentations/pycon2006/architecture-extending-and-embedding/demo/endnotes.py
blob: de9d2a49fee345b826f53ec2a90eda2a68ae1b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""
Move footnotes to the end of the document.
"""

from docutils import transforms
from docutils import nodes

class EndNotes(transforms.Transform):

    default_priority = 950
    
    def apply(self):
        all_footnotes = []
        assert isinstance(self.document, nodes.document)
        for footnote in self.document.traverse(nodes.footnote):
            all_footnotes.append(footnote)
            footnote.parent.remove(footnote)
        self.document += all_footnotes