|
| 1 | +# ST2/ST3 compat |
| 2 | +from __future__ import print_function |
| 3 | +import sublime |
| 4 | +if sublime.version() < '3000': |
| 5 | + # we are on ST2 and Python 2.X |
| 6 | + _ST3 = False |
| 7 | +else: |
| 8 | + _ST3 = True |
| 9 | + |
| 10 | +import os.path |
| 11 | +import re |
| 12 | +# This will work because makePDF.py puts the appropriate |
| 13 | +# builders directory in sys.path |
| 14 | +from pdfBuilder import PdfBuilder |
| 15 | + |
| 16 | +DEBUG = False |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +#---------------------------------------------------------------- |
| 22 | +# AutoLaTeXBuilder class |
| 23 | +# |
| 24 | +# Call the autolatex building tool. |
| 25 | +# |
| 26 | + |
| 27 | +class AutolatexBuilder(PdfBuilder): |
| 28 | + |
| 29 | + def __init__(self, tex_root, output, builder_settings, platform_settings): |
| 30 | + # Sets the file name parts, plus internal stuff |
| 31 | + super(AutolatexBuilder, self).__init__(tex_root, output, builder_settings, platform_settings) |
| 32 | + # Now do our own initialization: set our name, see if we want to display output |
| 33 | + self.name = "AutoLaTeX Builder" |
| 34 | + self.display_log = builder_settings.get("display_log", False) |
| 35 | + self.verbose_level = builder_settings.get("verbose_level", 2) |
| 36 | + |
| 37 | + def commands(self): |
| 38 | + # Print greeting |
| 39 | + self.display("\n\nAutolatexBuilder: ") |
| 40 | + |
| 41 | + autolatex = ["autolatex", "--stdout", "--noview", "--pdf", "--pdflatex", "--file="+self.tex_name, "--synctex"] |
| 42 | + for lvl in range(1, self.verbose_level): |
| 43 | + autolatex = autolatex + ["-v"] |
| 44 | + autolatex = autolatex + ["all"] |
| 45 | + |
| 46 | + # We have commands in our PATH, and are in the same dir as the master file |
| 47 | + |
| 48 | + # This is for debugging purposes |
| 49 | + def display_results(): |
| 50 | + if self.display_log: |
| 51 | + self.display("Command results:\n" ) |
| 52 | + self.display(self.out) |
| 53 | + self.display("\n") |
| 54 | + |
| 55 | + yield (autolatex, "autolatex run; ") |
| 56 | + display_results() |
| 57 | + |
| 58 | + self.display("done.\n") |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
0 commit comments