Last active
April 25, 2016 05:55
-
-
Save santiago-salas-v/7e0e434b8994559ded3b2d476a0f57d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make:image("png$", | |
"dvipng -bg Transparent -T tight -x 1400 -o ${output} -pp ${page} ${source}") | |
Make:match("html$", "tidy -m -xml -utf8 -q -i ${filename}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
import os | |
import subprocess | |
import threading | |
class HtlatexCommand(sublime_plugin.TextCommand): | |
def run(self, edit, filename=None): | |
filename = self.view.file_name() | |
th = HtlatexThread(filename) | |
if not filename is None and \ | |
os.path.splitext(filename)[1] == '.tex': | |
th.start() | |
class HtlatexThread(threading.Thread): | |
def __init__(self, filename=None): | |
self.filename = filename | |
threading.Thread.__init__(self) | |
def run(self): | |
first_dir = os.path.abspath(os.getcwd()) | |
new_file_with_dir = os.path.abspath(self.filename) | |
new_dir = os.path.dirname(new_file_with_dir) | |
filename = os.path.basename(new_file_with_dir) | |
os.chdir(new_dir) | |
makefile = [x for x in os.listdir(new_dir) if \ | |
os.path.splitext(x)[-1]=='.mk4'] | |
if filename is not None and \ | |
os.path.splitext(filename)[-1] == '.tex': | |
if len(makefile) > 0: | |
subprocess.Popen(['make4ht', filename, '-e', makefile[0]]) | |
else: | |
subprocess.Popen(['make4ht', filename]) | |
else: | |
pass | |
os.chdir(first_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": ["python", "-u", "$file"], | |
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
"selector": "source.python", | |
"shell":"true" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment