Przeglądaj źródła

Produce both draft and final PDFs

Ryan C. Thompson 5 lat temu
rodzic
commit
5c9f273607
2 zmienionych plików z 14 dodań i 1 usunięć
  1. 1 0
      .gitignore
  2. 13 1
      Snakefile

+ 1 - 0
.gitignore

@@ -20,3 +20,4 @@
 # LyX temp files
 tmp-*
 *-PROCESSED.*
+*-final.lyx

+ 13 - 1
Snakefile

@@ -186,7 +186,7 @@ def tex_gfx_extensions(tex_format = 'xetex'):
 rsync_common_args = ['-rL', '--size-only', '--delete', '--exclude', '.DS_Store', '--delete-excluded',]
 
 rule build_all:
-    input: 'thesis.pdf'
+    input: 'thesis.pdf', 'thesis-final.pdf'
 
 # Currently assumes the lyx file always exists, because it is required
 # to get the gfx and bib dependencies
@@ -205,6 +205,18 @@ rule lyx_to_pdf:
         if PDFINFO_PATH:
             shell('''{PDFINFO_PATH} {output.pdf:q}''')
 
+rule lyx_enable_final:
+    '''Produce a copy of a LyX.lyx file with the final option enabled.'''
+    input: lyxfile='{basename}.lyx'
+    output: lyxfile='{basename,.*(?<!-final)}-final.lyx'
+    run:
+        with open(input.lyxfile, 'r') as infile, \
+             open(output.lyxfile, 'w') as outfile:
+            lyx_text = infile.read()
+            if not regex.search('\\\\options final', lyx_text):
+                lyx_text = regex.sub('\\\\use_default_options true', '\\\\options final\n\\\\use_default_options true', lyx_text)
+            outfile.write(lyx_text)
+
 rule process_bib:
     '''Preprocess bib file for LaTeX.