Skip to content

Commit b113c0a

Browse files
Include the AutoLaTeX compiler with the builder API of LaTeXTools.
This commit is related to the issue #344.
1 parent 517c5a3 commit b113c0a

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

LaTeXTools.default-settings

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
// "traditional" replicates the 'old' system based on
8787
// latexmk (TeXLive) / texify (MiKTeX)
8888
//
89+
// "autolatex" invoke autolatex with the settings
90+
// specified in "builder_settings"
91+
//
8992
// "script" external script: just invokes the script
9093
// specified in "builder_settings"
9194
//
@@ -122,6 +125,9 @@
122125
// (built-ins): true shows the log of each command in the output panel
123126
"display_log" : false,
124127

128+
// (built-ins): the level of verbosity for the builder (greater or equal to 0)
129+
"verbose_level" : 2,
130+
125131
// Platform-specific settings:
126132
"osx" : {
127133
// See README or third-party documentation
@@ -174,4 +180,4 @@
174180
// Similarly, the formatting for the autocomplete panel:
175181
"cite_autocomplete_format": "{keyword}: {title}"
176182

177-
}
183+
}

builders/autolatexBuilder.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+

makePDF.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def run(self, cmd="", file_regex="", path=""):
259259

260260
# Safety check: if we are using a built-in builder, disregard
261261
# builder_path, even if it was specified in the pref file
262-
if builder_name in ['simple', 'traditional', 'script', 'default','']:
262+
if builder_name in ['simple', 'traditional', 'script', 'default','autolatex','']:
263263
builder_path = None
264264

265265
# Now actually get the builder

0 commit comments

Comments
 (0)