File: Footnotes.py

package info (click to toggle)
plastex 3.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,132 kB
  • sloc: python: 23,341; xml: 18,076; javascript: 7,755; ansic: 46; makefile: 40; sh: 26
file content (54 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
C.3.3 Footnotes (p172)

"""

from plasTeX import Command, DimenCommand


class footnote(Command):
    args = '[ num:int ] self'
    mark = None

    def invoke(self, tex):
        # Add the footnote to the document
        output = Command.invoke(self, tex)
        userdata = self.ownerDocument.userdata
        if 'footnotes' not in userdata:
            userdata['footnotes'] = []
        userdata['footnotes'].append(self)
        self.mark = self
        return output

class footnotemark(Command):
    args = '[ num:int ]'
    mark = None

    def invoke(self, tex):
        # Add the footnotemarks to the document
        output = Command.invoke(self, tex)
        userdata = self.ownerDocument.userdata
        if 'footnotemarks' not in userdata:
            userdata['footnotemarks'] = []
        userdata['footnotemarks'].append(self)
        self.mark = self
        return output

class footnotetext(footnote):
    args = '[ num:int ] self'
    mark = None
    
    def invoke(self, tex):
        output = footnote.invoke(self, tex)
        self.mark = self.ownerDocument.userdata.get('footnotemarks',[None]).pop(0)
        return output

#
# Style Parameters
#

class footnotesep(DimenCommand):
    value = DimenCommand.new(0)

class footnoterule(Command):
    pass