Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix some more thinngs.

  • Loading branch information...
commit 9006f296a612fa4d79b910fb1fcc247a13ba2d04 1 parent 56f373b
M. Tong authored
10 Default.sublime-commands
View
@@ -2,26 +2,26 @@
{
"caption": "Pandoc: Render Markdown to temp PDF and View",
"command": "pandoc_render",
- "args":{"openAfter":true, "target":"pdf", "saveResult":false}
+ "args":{"open_after":true, "target":"pdf", "save_result":false}
},
{
"caption": "Pandoc: Render Markdown to temp HTML and View",
"command": "pandoc_render",
- "args":{"openAfter":true, "target":"html", "saveResult":false}
+ "args":{"open_after":true, "target":"html", "save_result":false}
},
{
"caption": "Pandoc: Render Markdown to HTML",
"command": "pandoc_render",
- "args":{"openAfter":false, "target":"html", "saveResult":true}
+ "args":{"open_after":false, "target":"html", "save_result":true}
},
{
"caption": "Pandoc: Render Markdown to PDF",
"command": "pandoc_render",
- "args":{"openAfter":false, "target":"pdf", "saveResult":true}
+ "args":{"open_after":false, "target":"pdf", "save_result":true}
},
{
"caption": "Pandoc: Render Markdown DocX",
"command": "pandoc_render",
- "args":{"openAfter":false, "target":"docx", "saveResult":true}
+ "args":{"open_after":false, "target":"docx", "save_result":true}
}
]
81 Main.sublime-menu
View
@@ -1,36 +1,67 @@
[
{
- "id": "tools",
+ "caption": "Preferences",
+ "mnemonic": "n",
+ "id": "preferences",
"children":
[
{
- "caption": "Pandoc",
+ "caption": "Package Settings",
+ "mnemonic": "P",
+ "id": "package-settings",
"children":
[
{
- "caption": "Render Markdown to temporary PDF and View",
- "command": "pandoc_render",
- "args":{"openAfter":true, "target":"pdf", "saveResult":false}
- },
- {
- "caption": "Render Markdown to temporary HTML and View",
- "command": "pandoc_render",
- "args":{"openAfter":true, "target":"html", "saveResult":false}
- },
- {
- "caption": "Render Markdown to PDF",
- "command": "pandoc_render",
- "args":{"openAfter":false, "target":"pdf", "saveResult":true}
- },
- {
- "caption": "Render Markdown to HTML",
- "command": "pandoc_render",
- "args":{"openAfter":false, "target":"html", "saveResult":true}
- },
- {
- "caption": "Render Markdown DocX",
- "command": "pandoc_render",
- "args":{"openAfter":false, "target":"docx", "saveResult":true}
+ "caption": "SmartMarkdown",
+ "children":
+ [
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/SmartMarkdown/SmartMarkdown.sublime-settings"
+ },
+ "caption": "Settings – Default"
+ },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/User/SmartMarkdown.sublime-settings"
+ },
+ "caption": "Settings – User"
+ },
+ { "caption": "-" },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/SmartMarkdown/Default.sublime-keymap"
+ },
+ "caption": "Key Bindings – Default"
+ },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/User/Default (OSX).sublime-keymap",
+ "platform": "OSX"
+ },
+ "caption": "Key Bindings – User"
+ },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/User/Default (Linux).sublime-keymap",
+ "platform": "Linux"
+ },
+ "caption": "Key Bindings – User"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/User/Default (Windows).sublime-keymap",
+ "platform": "Windows"
+ },
+ "caption": "Key Bindings – User"
+ }
+ ]
}
]
}
4 SmartMarkdown.sublime-settings
View
@@ -1,5 +1,7 @@
{
/* Please specify the PATH of pdflatex if you wanna generate PDF */
"tex_path": ["/usr/local/texlive/2011/bin/x86_64-darwin",
- "/usr/local/texlive/2012/bin/x86_64-darwin"]
+ "/usr/local/texlive/2012/bin/x86_64-darwin"],
+ /* Provide your settings here as a list e.g.: ["--latex-engine=xelatex", "--toc"]*/
+ "pandoc_args": ["--toc"]
}
15 pandoc_render.py
View
@@ -44,7 +44,7 @@ def run(self, edit, target="pdf", open_after=True, save_result=False):
# output file...
suffix = "." + target
- if saveResult:
+ if save_result:
output_name = os.path.splitext(self.view.file_name())[0] + suffix
if not self.view.file_name():
raise Exception("Please safe the buffer before trying to export with pandoc.")
@@ -57,14 +57,19 @@ def run(self, edit, target="pdf", open_after=True, save_result=False):
self.run_pandoc(tmp_md.name, output_name, args)
os.unlink(tmp_md.name)
- if openAfter:
+ if open_after:
self.open_result(output_name, target)
def run_pandoc(self, infile, outfile, args):
- cmd = ['pandoc'] + args
+ setting = sublime.load_settings("SmartMarkdown.sublime-settings")
+
+ cmd = ['pandoc'] + setting.get("pandoc_args", []) + args
cmd += [infile, "-o", outfile]
+
+ setting_path = setting.get("tex_path", [])
+ os_path = os.environ["PATH"] + ":" + ":".join(setting_path)
try:
- subprocess.call(cmd)
+ subprocess.check_call(cmd, env={"PATH": os_path})
except Exception as e:
sublime.error_message("Unable to execute Pandoc. \n\nDetails: {0}".format(e))
@@ -86,7 +91,7 @@ def open_result(self, outfile, target):
webbrowser.open_new_tab(outfile)
elif sys.platform == "win32":
os.startfile(outfile)
- elif sys.platform == "mac":
+ elif "mac" in sys.platform or "darwin" in sys.platform:
subprocess.call(["open", outfile])
elif "posix" in sys.platform or "linux" in sys.platform:
subprocess.call(["xdg-open", outfile])
Please sign in to comment.
Something went wrong with that request. Please try again.