예제 #1
0
 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
예제 #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'
예제 #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'
예제 #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))
예제 #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)
예제 #6
0
파일: Numbers.py 프로젝트: we-taper/plastex
 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))
예제 #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))
예제 #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))
예제 #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)
예제 #10
0
 def testRomanNumeral(self):
     t = TeX()
     t.input(r'\romannumeral5')
     p = t.parse()
     assert ''.join(p) == 'v'
예제 #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
예제 #12
0
 def testActiveSource(self):
     t = TeX()
     t.input(r'~')
     t = t.parse()
     assert t.source.strip() == '~', t.source.strip()
예제 #13
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
예제 #14
0
 def testActiveSource(self):
     t = TeX()
     t.input(r'~')
     t = t.parse()
     assert t.source.strip() == '~', t.source.strip()
예제 #15
0
 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