Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Update for ST3
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Kuhlman committed Aug 10, 2013
1 parent f1284ef commit 59b6cd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Legal Markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ def run(self, edit):
self.get_selection_position()
self.active_view = self.view.window().active_view()
self.buffer_region = sublime.Region(0, self.active_view.size())
self.update_view(self.yamlize_buffer())
contents = self.yamlize_buffer()
self.view.erase(edit, self.buffer_region)
self.view.insert(edit, 0, contents)
self.view.end_edit(edit)
self.reset_selection_position()

def yamlize_buffer(self):
Expand All @@ -20,16 +23,13 @@ def yamlize_buffer(self):
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out = yamlizer.communicate(body.encode("utf-8"))[0].decode('utf8')
if (out == "" and body != ""):
sublime.error_message("check your ruby interpreter settings")
sublime.error_message("Something went wrong. Please check your Ruby Path settings. If it continues file an issue on Github.")
return body
else:
return out

def update_view(self, contents):
edit = self.view.begin_edit()
self.view.erase(edit, self.buffer_region)
self.view.insert(edit, 0, contents)
self.view.end_edit(edit)
# def update_view(self, contents):
# edit = self.view.begin_edit()

def reset_selection_position(self):
self.view.sel().clear()
Expand All @@ -47,7 +47,7 @@ def cmd(self, path = "-"):
ruby_script = os.path.join(sublime.packages_path(), "Legal Document Creator", "lib", 'legal_markdown.rb')
args = ["--headers", "-", "-"]
command = ruby_interpreter + " '" + ruby_script + "' " + ' '.join(args)
print command
print(command)
return command

class LegalMarkdownToNormalMarkdown(sublime_plugin.WindowCommand):
Expand Down Expand Up @@ -87,13 +87,13 @@ class LegalMarkdownExport(sublime_plugin.WindowCommand):
def run(self):
self.active_view = self.window.active_view()
self.buffer_region = sublime.Region(0, self.active_view.size())
self.window.show_quick_panel(self.get_the_settings('build-formats').keys(), self.build_new_format)
self.window.show_quick_panel(list(self.get_the_settings('build-formats').keys()), self.build_new_format)

def build_new_format(self, format_to):
formats = self.get_the_settings('build-formats')
if format_to == -1:
return
format_to = formats[formats.keys()[format_to]]
format_to = formats[list(formats.keys())[format_to]]
view = self.window.active_view()

# string to work with
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Introduction

*Tested in ST2 and ST3*

This package is meant to help build legal documents in Sublime. There are two components of the package at this point. The first is a set of language files for syntax highlighting `lmd` files in Sublime. The second is a set of features to build and export documents using `lmd` syntax. This set of features will:

* Automate the building of the `lmd` YAML Front Matter
Expand Down

0 comments on commit 59b6cd6

Please sign in to comment.