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
def testRomanNumeralSection(self): t = TeX() t.input(r''' \documentclass{article} \begin{document} \section{} \section{} \romannumeral\thesection \end{document} ''') assert t.parse().textContent.strip() == 'ii'
def testNumberSection(self): t = TeX() t.input(r''' \documentclass{article} \begin{document} \section{} \section{} \number\thesection \end{document} ''') assert t.parse().textContent.strip() == '2'
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))
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)
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))
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))
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)
def testRomanNumeral(self): t = TeX() t.input(r'\romannumeral5') p = t.parse() assert ''.join(p) == 'v'
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