Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/book/localdef.py
Views: 531
import plasTeX.Base as Base12def idgen():3""" Generate a unique ID """4i = 15while 1:6yield 'a%.10d' % i7i += 189idgen = idgen()1011class Eqn(Base.Command):12args = 'self'1314class Anchor(Base.Command):15args = 'label:str'16def invoke(self, tex):17Base.Command.invoke(self, tex)18self.ownerDocument.context.label(self.attributes['label'], self)1920class exercise(Base.Environment):21counter = 'exercise'2223class index(Base.Command):24args = 'termstring'2526def setEntry(self, s, seetype=0):27# TYPE_NORMAL = 028# TYPE_SEE = 129# TYPE_SEEALSO = 230if type(s) != type(''):31s = s.textContent32if s.count('!'):33priterm, secterm = s.split('!')34if priterm.count('@'):35prisort, primary = priterm.split('@')36else:37prisort, primary = None, priterm38if secterm.count('@'):39secsort, secondary = secterm.split('@')40else:41secsort, secondary = None, secterm42elif s.count('@'):43prisort, primary = s.split('@')44secsort, secondary = None, None45else:46prisort, primary = None, s47secsort, secondary = None, None4849# if secondary:50# self.ownerDocument.userdata.setdefault('index', []).append(\51# Base.IndexEntry([primary, secondary], self, [prisort, secsort], None, type=seetype))52# else:53# self.ownerDocument.userdata.setdefault('index', []).append(\54# Base.IndexEntry([primary], self, [prisort], None, type=seetype))55return prisort, primary, secsort, secondary5657def invoke(self, tex):58Base.Command.invoke(self, tex)59self.ownerDocument.context.label(idgen.next(), self)60p0,p1,s0,s1 = self.setEntry(self.attributes['termstring'])61if p0:62self.prisort = '%s' % p063if p1:64self.primary = '%s' % p165if s0:66self.secsort = '%s' % s067if s1:68self.secondary = '%s' % s16970class scriptN(Base.Command):71unicode = u'\U0001D4A9'7273class uxbar(Base.Command): pass74class uybar(Base.Command): pass75class unhat(Base.Command): pass76class ule(Base.Command): pass77class minus(Base.Command): pass78class lowast(Base.Command): pass79class Erdos(Base.Command): pass80818283