def testTeXNumber(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('100')
        arg = s.readArgument(type='Number')
        assert arg == count('100'), arg

        # Set by other dimen
        s.input(r'\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('120'), arg

        # Multiply by other dimen
        s.input(r'3\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('360'), arg

        # No number
        s.input('{0}')
        arg = s.readArgument(type='Number')
        assert arg == count(0), arg

        assert ParameterCommand._enablelevel == 0
    def testNumber(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, this will only parse the `1`
        s.input('100')
        arg = s.readArgument(type='number')
        assert arg == count(1), arg

        # Literal number
        s.input('{100}')
        arg = s.readArgument(type='number')
        assert arg == count(100), arg

        # Set by other number
        s.input(r'\mycount')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Set by other number
        s.input(r'{\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Multiply by other number
        s.input(r'{5\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(600), arg

        # No number
        s.input('{a}')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # No number
        s.input('b')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # Coerced dimen
        s.input(r'{\mydimen}')
        arg = s.readArgument(type='number')
        assert arg == count(12), arg

        # Coerced glue
        s.input(r'{\myglue}')
        arg = s.readArgument(type='number')
        assert arg == count(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 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 testTeXNumber(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('100')
        arg = s.readArgument(type='Number')
        assert arg == count('100'), arg

        # Set by other dimen
        s.input(r'\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('120'), arg

        # Multiply by other dimen
        s.input(r'3\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('360'), arg

        # No number
        s.input('{0}')
        arg = s.readArgument(type='Number')
        assert arg == count(0), 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 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 testNumber(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, this will only parse the `1`
        s.input('100')
        arg = s.readArgument(type='number')
        assert arg == count(1), arg

        # Literal number
        s.input('{100}')
        arg = s.readArgument(type='number')
        assert arg == count(100), arg

        # Set by other number
        s.input(r'\mycount')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Set by other number
        s.input(r'{\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Multiply by other number
        s.input(r'{5\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(600), arg

        # No number
        s.input('{a}')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # No number
        s.input('b')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # Coerced dimen
        s.input(r'{\mydimen}')
        arg = s.readArgument(type='number')
        assert arg == count(12), arg

        # Coerced glue
        s.input(r'{\myglue}')
        arg = s.readArgument(type='number')
        assert arg == count(10), arg

        assert ParameterCommand._enablelevel == 0
Example #7
0
    def newskip(self, name, initial=0):
        """
        Create a new glue (like \\newskip)

        Required Arguments:
        name -- name of glue to create

        Keyword Arguments:
        initial -- value to initialize to

        """
        # Generate a new glue class
        macrolog.debug('creating dimen %s', name)
        newclass = type(name, (plasTeX.GlueCommand,),
                                {'value': plasTeX.glue(initial)})
        self.addGlobal(name, newclass)
Example #8
0
    def newskip(self, name, initial=0):
        """ 
        Create a new glue (like \\newskip)

        Required Arguments:
        name -- name of glue to create
      
        Keyword Arguments:
        initial -- value to initialize to

        """
        name = str(name)
        # Generate a new glue class
        macrolog.debug('creating dimen %s', name)
        newclass = new.classobj(name, (plasTeX.GlueCommand,), 
                                {'value': plasTeX.glue(initial)})
        self.addGlobal(name, newclass)
Example #9
0
class LTleft(GlueCommand):
    value = glue('1fil')
Example #10
0
class LTpost(GlueCommand):
    value = glue('1fil')
Example #11
0
class LTpre(GlueCommand):
    value = glue('1fil')
Example #12
0
class LTright(GlueCommand):
    value = glue('1fil')
Example #13
0
class LTpost(GlueCommand): value = glue('1fil')
class LTchunksize(DimenCommand): value = dimen('4in')