Expanded SCons.Scanner.LaTeX.comment_re to not break on \%
[scons.git] / test / TEX / multi-line_include_options.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 When an inclusion's optional argument (enclosed in square brackets:
29 []) spans multiple lines (via comment wrapping), ensure that the LaTeX
30 Scanner doesn't throw an IndexError.
31
32 An example of this in the wild is in Thomas Heim's epsdice LaTeX package:
33   \includegraphics[height=1.75ex,viewport= 3 4 38 39,%
34   clip=true]{\dicefile}%
35 In epsdice 2007/02/15, v. 2.1.
36 """
37
38 import TestSCons
39
40 _exe = TestSCons._exe
41
42 test = TestSCons.TestSCons()
43
44 test.write('SConstruct', """\
45 env = Environment()
46 env.DVI('root.tex')
47 """)
48
49 test.write('root.tex',
50 r"""\documentclass{article}
51 \usepackage{graphicx}
52 \begin{document}
53   \includegraphics[height=1.75ex,%
54   clip=true]{square}
55 \end{document}
56 """)
57
58 # Dummy EPS file drawing a square
59 test.write('square.eps',
60 r"""%!PS-Adobe-2.0 EPSF-1.2
61 %%BoundingBox: 0 0 20 20
62  newpath
63   5 5 moveto
64  15 5 lineto
65  15 15 lineto
66  5 15 lineto
67  5  5 lineto
68  stroke
69 %%EOF
70 """)
71
72 test.run(arguments = '.')
73
74 test.must_exist(test.workpath('root.dvi'))
75 test.must_exist(test.workpath('root.log'))
76
77 test.pass_test()
78
79 # Local Variables:
80 # tab-width:4
81 # indent-tabs-mode:nil
82 # End:
83 # vim: set expandtab tabstop=4 shiftwidth=4: