diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-31 18:56:23 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-31 18:56:23 -0400 |
commit | 09aeccd1a88e89187ec986f09db72247ee65080d (patch) | |
tree | f44961d197162e7023f6caa34e2bf07e5e1f1610 | |
parent | a1214e0740efd539abe544bad06dee44c2d467fe (diff) |
Support including .bbl files.
-rwxr-xr-x | tex-un-include | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tex-un-include b/tex-un-include index 72d7998..440c626 100755 --- a/tex-un-include +++ b/tex-un-include | |||
@@ -2,9 +2,10 @@ | |||
2 | 2 | ||
3 | import sys | 3 | import sys |
4 | import re | 4 | import re |
5 | from os import path | ||
5 | 6 | ||
6 | comment_re = re.compile(r'([^\\]|^)%') | 7 | comment_re = re.compile(r'([^\\]|^)%') |
7 | input_re = re.compile(r'\\input\{([^}]*)\}') | 8 | input_re = re.compile(r'\\(?:input|bibliography)\{([^}]*)\}') |
8 | 9 | ||
9 | def strip_comment(line): | 10 | def strip_comment(line): |
10 | g = comment_re.search(line) | 11 | g = comment_re.search(line) |
@@ -21,12 +22,13 @@ def chomp(line): | |||
21 | return line | 22 | return line |
22 | 23 | ||
23 | def open_tex_file(fname, mode='r'): | 24 | def open_tex_file(fname, mode='r'): |
24 | try: | 25 | if path.exists(fname + '.bbl'): |
25 | f = open(fname, mode) | 26 | # try bibliography file |
26 | except IOError: | 27 | fname += '.bbl' |
27 | # try again with .tex appended | 28 | elif path.exists(fname + '.tex'): |
28 | f = open(fname + '.tex', mode) | 29 | # try tex file |
29 | return f | 30 | fname += '.tex' |
31 | return open(fname, mode) | ||
30 | 32 | ||
31 | def process_file(fname, out=sys.stdout): | 33 | def process_file(fname, out=sys.stdout): |
32 | for line in open_tex_file(fname): | 34 | for line in open_tex_file(fname): |