summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner/LaTeX.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-11-20 03:11:08 (GMT)
committerSteven Knight <knight@baldmt.com>2005-11-20 03:11:08 (GMT)
commit78ed211cbfcb68bd3af0885f117bb0f75819c305 (patch)
treeaebc1df0a72b0ce30b82d51802a2c41aa9ac6c26 /src/engine/SCons/Scanner/LaTeX.py
parenta63e48e4d02da4d7fa5bbebd2d2b3b18da287cfb (diff)
downloadSCons-78ed211cbfcb68bd3af0885f117bb0f75819c305.zip
SCons-78ed211cbfcb68bd3af0885f117bb0f75819c305.tar.gz
SCons-78ed211cbfcb68bd3af0885f117bb0f75819c305.tar.bz2
Have the LaTeX scanner also look for \includegraphics{} strings.
Diffstat (limited to 'src/engine/SCons/Scanner/LaTeX.py')
-rw-r--r--src/engine/SCons/Scanner/LaTeX.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py
index 22a5e87..6451a58 100644
--- a/src/engine/SCons/Scanner/LaTeX.py
+++ b/src/engine/SCons/Scanner/LaTeX.py
@@ -1,6 +1,6 @@
"""SCons.Scanner.LaTeX
-This module implements the dependency scanner for LaTeX code.
+This module implements the dependency scanner for LaTeX code.
"""
@@ -35,15 +35,32 @@ import SCons.Scanner
def LaTeXScanner(fs = SCons.Node.FS.default_fs):
"""Return a prototype Scanner instance for scanning LaTeX source files"""
ds = LaTeX(name = "LaTeXScanner",
- suffixes = '$LATEXSUFFIXES',
- path_variable = 'TEXINPUTS',
- regex = '\\\\(?:include|input){([^}]*)}',
- recursive = 0)
+ suffixes = '$LATEXSUFFIXES',
+ path_variable = 'TEXINPUTS',
+ regex = '\\\\(include|includegraphics(?:\[[^\]]+\])?|input){([^}]*)}',
+ recursive = 0)
return ds
class LaTeX(SCons.Scanner.Classic):
+ """Class for scanning LaTeX files for included files.
+
+ Unlike most scanners, which use regular expressions that just
+ return the included file name, this returns a tuple consisting
+ of the keyword for the inclusion ("include", "includegraphics" or
+ "input"), and then the file name itself. Base on a quick look at
+ LaTeX documentation, it seems that we need a should append .tex
+ suffix for "include" and "input" keywords, but leave the file name
+ untouched for "includegraphics."
+ """
+ def latex_name(self, include):
+ filename = include[1]
+ if include[0][:15] != 'includegraphics':
+ filename = filename + '.tex'
+ return filename
+ def sort_key(self, include):
+ return SCons.Node.FS._my_normcase(self.latex_name(include))
def find_include(self, include, source_dir, path):
if callable(path): path=path()
- i = SCons.Node.FS.find_file(include + '.tex',
+ i = SCons.Node.FS.find_file(self.latex_name(include),
(source_dir,) + path)
return i, include