def testTeXDimen(self): s = TeX() s.input(r'''\newcount\mycount\mycount=120 \newdimen\mydimen\mydimen=12sp \newskip\myglue\myglue=10sp plus1pt minus2pt''') s.parse() value = s.ownerDocument.context['mycount'].value assert value == count(120), value value = s.ownerDocument.context['mydimen'].value assert value == dimen('12sp'), value value = s.ownerDocument.context['myglue'].value assert value == glue('10sp', plus='1pt', minus='2pt'), value # Literal dimension s.input(r'3.5pt') arg = s.readArgument(type='Dimen') assert arg == dimen('3.5pt'), arg # Literal dimension, {...} aren't allowed s.input(r'{3.5pt}') arg = s.readArgument(type='Dimen') assert arg == dimen(0), arg # Set by other dimension s.input(r'\mydimen') arg = s.readArgument(type='Dimen') assert arg == dimen('12sp'), arg # Set by count s.input(r'\mycount') arg = s.readArgument(type='Dimen') assert arg == dimen('120sp'), arg assert ParameterCommand._enablelevel == 0
def testDimen(self): s = TeX() s.input(r'''\newcount\mycount\mycount=120 \newdimen\mydimen\mydimen=12sp \newskip\myglue\myglue=10sp plus1pt minus2pt''') s.parse() value = s.ownerDocument.context['mycount'].value assert value == count(120), value value = s.ownerDocument.context['mydimen'].value assert value == dimen('12sp'), value value = s.ownerDocument.context['myglue'].value assert value == glue('10sp', plus='1pt', minus='2pt'), value # Literal dimension, this will only parse the `3` s.input(r'3.5pt') arg = s.readArgument(type='dimen') assert arg == dimen('3.0pt'), arg # Literal dimension s.input(r'{3.5pt}') arg = s.readArgument(type='dimen') assert arg == dimen('3.5pt'), arg # Set by other dimension s.input(r'\mydimen') arg = s.readArgument(type='dimen') assert arg == dimen('12sp'), arg # Set by other dimension s.input(r'{\mydimen}') arg = s.readArgument(type='dimen') assert arg == dimen('12sp'), arg # Multiply by other dimension s.input(r'{3.0\mydimen}') arg = s.readArgument(type='dimen') assert arg == dimen('36sp'), arg # No number s.input('{a}') arg = s.readArgument(type='dimen') assert arg == dimen(0), arg # No number s.input('b') arg = s.readArgument(type='dimen') assert arg == dimen(0), arg # Coerced dimen s.input(r'{\mycount}') arg = s.readArgument(type='dimen') assert arg == dimen(120), arg # Coerced glue s.input(r'{\myglue}') arg = s.readArgument(type='dimen') assert arg == dimen(10), arg assert ParameterCommand._enablelevel == 0
def testTeXDimen(self): s = TeX() s.input(r'''\newcount\mycount\mycount=120 \newdimen\mydimen\mydimen=12sp \newskip\myglue\myglue=10sp plus1pt minus2pt''') s.parse() value = s.ownerDocument.context['mycount'].value assert value == count(120), value value = s.ownerDocument.context['mydimen'].value assert value == dimen('12sp'), value value = s.ownerDocument.context['myglue'].value assert value == glue('10sp', plus='1pt', minus='2pt'), value # Literal number s.input('100pt') arg = s.readArgument(type='Dimen') assert arg == dimen('100pt'), arg # Set by other dimen s.input(r'\mydimen') arg = s.readArgument(type='Dimen') assert arg == dimen('12sp'), arg # Multiply by other dimen s.input(r'3\mydimen') arg = s.readArgument(type='Dimen') assert arg == dimen('36sp'), arg # No number s.input('{0}') arg = s.readArgument(type='Dimen') assert arg == dimen(0), arg assert ParameterCommand._enablelevel == 0
def ProcessOptions(options, document): empty = TeXFragment() bf = TeXFragment() bf.ownerDocument = document bf.append(bfseries(), False) it = TeXFragment() it.ownerDocument = document it.append(itshape(), False) document.userdata.setPath( 'packages/amsthm/styles', { 'plain': { 'name': 'plain', 'above': dimen('0pt'), 'below': dimen('0pt'), 'bodyfont': it, 'indentamount': dimen('0pt'), 'headfont': bf, 'punctuation': ".", 'between': ' ', 'headspec': None }, 'definition': { 'name': 'definition', 'above': dimen('0pt'), 'below': dimen('0pt'), 'bodyfont': empty, 'indentamount': dimen('0pt'), 'headfont': bf, 'punctuation': ".", 'between': ' ', 'headspec': None }, 'remark': { 'name': 'remark', 'above': dimen("0pt"), 'below': dimen("0pt"), 'bodyfont': empty, 'indentamount': dimen('0pt'), 'headfont': bf, 'punctuation': ".", 'between': ' ', 'headspec': None } }) document.userdata.setPath('packages/amsthm/theorems', []) document.userdata.setPath('packages/amsthm/currentstyle', 'plain') cb = PackagePreCleanupCB(renderers='html5', data=make_amsthm_css) css = PackageCss(renderers='html5', path=Path('amsthm.css')) css.copy = False document.addPackageResource([cb, css])
def newdimen(self, name, initial=0): """ Create a new dimen (like \\newdimen) Required Arguments: name -- name of dimen to create Keyword Arguments: initial -- value to initialize to """ # Generate a new dimen class macrolog.debug('creating dimen %s', name) newclass = type(name, (plasTeX.DimenCommand,), {'value': plasTeX.dimen(initial)}) self.addGlobal(name, newclass)
def newdimen(self, name, initial=0): """ Create a new dimen (like \\newdimen) Required Arguments: name -- name of dimen to create Keyword Arguments: initial -- value to initialize to """ name = str(name) # Generate a new dimen class macrolog.debug('creating dimen %s', name) newclass = new.classobj(name, (plasTeX.DimenCommand,), {'value': plasTeX.dimen(initial)}) self.addGlobal(name, newclass)
class LTchunksize(DimenCommand): value = dimen('4in')
class LTchunksize(DimenCommand): value = dimen('4in') class LTchunksize(CountCommand): value = count(20)