forked from victorporof/Sublime-HTMLPrettify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTMLPrettify.py
More file actions
24 lines (20 loc) · 723 Bytes
/
Copy pathHTMLPrettify.py
File metadata and controls
24 lines (20 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import commands, re
import sublime, sublime_plugin
class HtmlprettifyCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.save()
self.prettify(edit)
def save(self):
self.view.run_command("save")
def prettify(self, edit):
regx = re.compile(" ")
html = commands.getoutput("node " +
regx.sub("\ ", sublime.packages_path()) + "/HTMLPrettify/scripts/run.js " +
regx.sub("\ ", self.view.file_name()) +
" indent_size:\ 2" +
" indent_char:\ ' '" +
" max_char:\ 80" +
" brace_style:\ collapse")
if len(html) > 0:
self.view.replace(edit, sublime.Region(0, self.view.size()), html.decode('utf-8'))
sublime.set_timeout(self.save, 100)