File: amsmath.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 (139 lines) | stat: -rw-r--r-- 2,860 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
from plasTeX import Command
from plasTeX.Base.LaTeX.Arrays import Array
from plasTeX.Base.LaTeX.Math import EqnarrayStar, eqnarray
#### Imports Added by Tim ####
from plasTeX.Base.LaTeX.Math import math, MathEnvironmentPre

from plasTeX import Tokenizer
from plasTeX.Logging import getLogger

deflog = getLogger('parse.definitions')

class pmatrix(Array):
    pass

class _AMSEquation(eqnarray):
    pass

class _AMSEquationStar(EqnarrayStar):
    macroName = None

class align(_AMSEquation):
    pass

class AlignStar(_AMSEquationStar):
    macroName = 'align*'

class gather(_AMSEquation):
    pass

class GatherStar(_AMSEquationStar):
    macroName = 'gather*'

class falign(_AMSEquation):
    pass

class FAlignStar(_AMSEquationStar):
    macroName = 'falign*'

class multiline(_AMSEquation):
    pass

class MultilineStar(_AMSEquationStar):
    macroName = 'multiline*'

class alignat(_AMSEquation):
    args = 'column:int'

class AlignatStar(_AMSEquationStar):
    args = 'column:int'
    macroName = 'alignat*'

class split(_AMSEquation):
    pass

#### Added by Tim ####
class EquationStar(_AMSEquationStar):
    macroName = 'equation*'

class aligned(_AMSEquationStar):
    pass

class gathered(MathEnvironmentPre):
    pass

class cases(_AMSEquation):
    pass

class flalign(_AMSEquation):
    pass
class FlalignStar(_AMSEquationStar):
    macroName = 'flalign*'

class subequations(_AMSEquation):
    pass

class xalignat(alignat):
    pass

class multline(multiline):
    pass
class MultlineStar(MultilineStar):
    macroName = 'multline*'

class matrix(Array):
    pass

class vmatrix(Array):
    pass
class Vmatrix(Array):
    pass

class bmatrix(Array):
    pass
class Bmatrix(Array):
    pass

class smallmatrix(Array):
    pass

class dddot(math):
    pass

class ddddot(math):
    pass

class DeclareMathOperator(Command):
    args = '* name:cs definition:nox'
    def invoke(self, tex):
        self.parse(tex)
        a = self.attributes
        if a.get('*modifier*'):
            macro = r'\operatorname*'
        else:
            macro = r'\operatorname'
        definition = [Tokenizer.Token(macro), Tokenizer.Token('{')] + a['definition']+[Tokenizer.Token('}')]
        args = (a['name'], 0, definition)
        deflog.debug('math operator %s %s', *args)
        self.ownerDocument.context.newcommand(*args)


class numberwithin(Command):
    args = 'target:str control:str'

    def invoke(self, tex):
        self.parse(tex)
        control = self.attributes['control']
        target = self.attributes['target']
        ctx = self.ownerDocument.context

        # Resetting
        target_cnt = ctx.counters[target]
        target_cnt.resetby = control

        # Formatting
        ctx['the'+target].format = '{}.${{{}}}'.format(
                ctx['the'+control].format, target)

class eqref(Command):
    args = 'label:idref'