summaryrefslogtreecommitdiffstats
path: root/ast/doincludes
diff options
context:
space:
mode:
Diffstat (limited to 'ast/doincludes')
-rwxr-xr-xast/doincludes22
1 files changed, 22 insertions, 0 deletions
diff --git a/ast/doincludes b/ast/doincludes
new file mode 100755
index 0000000..656b0ac
--- /dev/null
+++ b/ast/doincludes
@@ -0,0 +1,22 @@
+#! /usr/bin/env perl
+
+# Reads a Latex file which contains \include{file} commands and writes
+# the document to standard output with the text of the included files
+# inserted.
+
+# Read input lines.
+ while ( <> ) {
+
+# Spot the \include{file} lines and extract the file name.
+ if ( ( $file ) = /^ *\\include{(.*)} *$/ ) {
+
+# Read the contents of the included file.
+ open( INCLUDE, $file . ".tex" );
+ while ( <INCLUDE> ) { print; }
+ close( INCLUDE );
+
+# Output other lines unchanged.
+ } else {
+ print;
+ }
+ }