def testActive2(self):
     t = TeX()
     t.input(
         r'\catcode`|=\active\catcode`/=\active \def|#1{\textbf{#1}/} \def/{\textit{the end}} |{bold text}'
     )
     output = t.parse()
     assert output[-2].nodeName == 'textbf', output[-2].nodeName
     assert output[-1].nodeName == 'textit', output[-1].nodeName
Beispiel #2
0
    def testRomanNumeralSection(self):
        t = TeX()
        t.input(r'''
\documentclass{article}
\begin{document}
\section{}
\section{}
\romannumeral\thesection
\end{document}
''')
        assert t.parse().textContent.strip() == 'ii'
Beispiel #3
0
    def testNumberSection(self):
        t = TeX()
        t.input(r'''
\documentclass{article}
\begin{document}
\section{}
\section{}
\number\thesection
\end{document}
''')
        assert t.parse().textContent.strip() == '2'
Beispiel #4
0
    def testDimenParameters(self):
        t = TeX()
        t.input(r'\newdimen\foo\foo=\hsize')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        hsize = t.ownerDocument.context['hsize'].value
        assert foo == hsize, '"%s" != "%s"' % (foo, hsize)

        t = TeX()
        t.input(r'\newdimen\foo\foo=7.6\hsize')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        hsize = t.ownerDocument.context['hsize'].value
        assert foo == (7.6 * hsize), '"%s" != "%s"' % (foo, 7.6 * hsize)

        t = TeX()
        t.input(r'\newdimen\foo\foo=-4\hsize')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        hsize = t.ownerDocument.context['hsize'].value
        assert foo == (-4 * hsize), '"%s" != "%s"' % (foo, (-4 * hsize))
Beispiel #5
0
    def testParameters(self):
        t = TeX()
        t.input(r'\newcount\foo\foo=\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == tolerance, '"%s" != "%s"' % (foo, tolerance)

        t = TeX()
        t.input(r'\newcount\foo\foo=7\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == (7 * tolerance), '"%s" != "%s"' % (foo, 7 * tolerance)

        t = TeX()
        t.input(r'\newcount\foo\foo=-3\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == (-3 * tolerance), '"%s" != "%s"' % (foo, -3 * tolerance)
Beispiel #6
0
 def testGlueParameters(self):
     t = TeX()
     t.input(r'\newskip\foo\foo=\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == baselineskip, '"%s" != "%s"' % (foo, baselineskip)
     
     t = TeX()
     t.input(r'\newskip\foo\foo=7.6\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == (7.6*baselineskip), '"%s" != "%s"' % (foo, 7.6*baselineskip)
     
     t = TeX()
     t.input(r'\newskip\foo\foo=-4\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == (-4*baselineskip), '"%s" != "%s"' % (foo, (-4*baselineskip))
Beispiel #7
0
 def testGlueParameters(self):
     t = TeX()
     t.input(r'\newskip\foo\foo=\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == baselineskip, '"%s" != "%s"' % (foo, baselineskip)
     
     t = TeX()
     t.input(r'\newskip\foo\foo=7.6\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == (7.6*baselineskip), '"%s" != "%s"' % (foo, 7.6*baselineskip)
     
     t = TeX()
     t.input(r'\newskip\foo\foo=-4\baselineskip')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     baselineskip = t.ownerDocument.context['baselineskip'].value
     assert foo == (-4*baselineskip), '"%s" != "%s"' % (foo, (-4*baselineskip))
Beispiel #8
0
 def testDimenParameters(self):
     t = TeX()
     t.input(r'\newdimen\foo\foo=\hsize')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     hsize = t.ownerDocument.context['hsize'].value
     assert foo == hsize, '"%s" != "%s"' % (foo, hsize)
     
     t = TeX()
     t.input(r'\newdimen\foo\foo=7.6\hsize')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     hsize = t.ownerDocument.context['hsize'].value
     assert foo == (7.6*hsize), '"%s" != "%s"' % (foo, 7.6*hsize)
     
     t = TeX()
     t.input(r'\newdimen\foo\foo=-4\hsize')
     t.parse()
     foo = t.ownerDocument.context['foo'].value
     hsize = t.ownerDocument.context['hsize'].value
     assert foo == (-4*hsize), '"%s" != "%s"' % (foo, (-4*hsize))
Beispiel #9
0
    def testParameters(self):
        t = TeX()
        t.input(r'\newcount\foo\foo=\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == tolerance, '"%s" != "%s"' % (foo, tolerance)

        t = TeX()
        t.input(r'\newcount\foo\foo=7\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == (7*tolerance), '"%s" != "%s"' % (foo, 7*tolerance)

        t = TeX()
        t.input(r'\newcount\foo\foo=-3\tolerance')
        t.parse()
        foo = t.ownerDocument.context['foo'].value
        tolerance = t.ownerDocument.context['tolerance'].value
        assert foo == (-3*tolerance), '"%s" != "%s"' % (foo, -3*tolerance)
Beispiel #10
0
 def testRomanNumeral(self):
     t = TeX()
     t.input(r'\romannumeral5')
     p = t.parse()
     assert ''.join(p) == 'v'
Beispiel #11
0
 def testActive(self):
     t = TeX()
     t.input(r'\catcode`|=\active \def|#1{\bf#1} |{bold text}')
     output = t.parse()
     assert output[-1].nodeName == 'bf', output[-1].nodeName
Beispiel #12
0
 def testActiveSource(self):
     t = TeX()
     t.input(r'~')
     t = t.parse()
     assert t.source.strip() == '~', t.source.strip()
 def testActive(self):
     t = TeX()
     t.input(r'\catcode`|=\active \def|#1{\bf#1} |{bold text}')
     output = t.parse()
     assert output[-1].nodeName == 'bf', output[-1].nodeName
 def testActiveSource(self):
     t = TeX()
     t.input(r'~')
     t = t.parse()
     assert t.source.strip() == '~', t.source.strip()
 def testActive2(self):
     t = TeX()
     t.input(r'\catcode`|=\active\catcode`/=\active \def|#1{\textbf{#1}/} \def/{\textit{the end}} |{bold text}')
     output = t.parse()
     assert output[-2].nodeName == 'textbf', output[-2].nodeName
     assert output[-1].nodeName == 'textit', output[-1].nodeName