Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96108
License: OTHER
1
import plasTeX.Base as Base
2
3
def idgen():
4
""" Generate a unique ID """
5
i = 1
6
while 1:
7
yield 'a%.10d' % i
8
i += 1
9
10
idgen = idgen()
11
12
class Eqn(Base.Command):
13
args = 'self'
14
15
class Anchor(Base.Command):
16
args = 'label:str'
17
def invoke(self, tex):
18
Base.Command.invoke(self, tex)
19
self.ownerDocument.context.label(self.attributes['label'], self)
20
21
class exercise(Base.Environment):
22
counter = 'exercise'
23
24
class index(Base.Command):
25
args = 'termstring'
26
27
def setEntry(self, s, seetype=0):
28
# TYPE_NORMAL = 0
29
# TYPE_SEE = 1
30
# TYPE_SEEALSO = 2
31
if type(s) != type(''):
32
s = s.textContent
33
if s.count('!'):
34
priterm, secterm = s.split('!')
35
if priterm.count('@'):
36
prisort, primary = priterm.split('@')
37
else:
38
prisort, primary = None, priterm
39
if secterm.count('@'):
40
secsort, secondary = secterm.split('@')
41
else:
42
secsort, secondary = None, secterm
43
elif s.count('@'):
44
prisort, primary = s.split('@')
45
secsort, secondary = None, None
46
else:
47
prisort, primary = None, s
48
secsort, secondary = None, None
49
50
# if secondary:
51
# self.ownerDocument.userdata.setdefault('index', []).append(\
52
# Base.IndexEntry([primary, secondary], self, [prisort, secsort], None, type=seetype))
53
# else:
54
# self.ownerDocument.userdata.setdefault('index', []).append(\
55
# Base.IndexEntry([primary], self, [prisort], None, type=seetype))
56
return prisort, primary, secsort, secondary
57
58
def invoke(self, tex):
59
Base.Command.invoke(self, tex)
60
self.ownerDocument.context.label(idgen.next(), self)
61
p0,p1,s0,s1 = self.setEntry(self.attributes['termstring'])
62
if p0:
63
self.prisort = '%s' % p0
64
if p1:
65
self.primary = '%s' % p1
66
if s0:
67
self.secsort = '%s' % s0
68
if s1:
69
self.secondary = '%s' % s1
70
71
class scriptN(Base.Command):
72
unicode = u'\U0001D4A9'
73
74
class uxbar(Base.Command): pass
75
class uybar(Base.Command): pass
76
class unhat(Base.Command): pass
77
class ule(Base.Command): pass
78
class minus(Base.Command): pass
79
class lowast(Base.Command): pass
80
class Erdos(Base.Command): pass
81
82
83