Created
July 22, 2013 14:15
-
-
Save dbaltas/6054139 to your computer and use it in GitHub Desktop.
Revisions
-
dbaltas created this gist
Jul 22, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import sublime, sublime_plugin, subprocess class TidyXmlLintCommand(sublime_plugin.TextCommand): def run(self, edit): command = "XMLLINT_INDENT='\t' xmllint --format --encode utf-8 -" # help from http://www.sublimetext.com/forum/viewtopic.php?f=2&p=12451 xmlRegion = sublime.Region(0, self.view.size()) p = subprocess.Popen(command, bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) result, err = p.communicate(self.view.substr(self.view.sel()[0]).encode('utf-8')) if err != b"": self.view.set_status('xmllint', "xmllint: "+err) sublime.set_timeout(self.clear,10000) else: self.view.replace(edit, self.view.sel()[0], result.decode('utf-8')) sublime.set_timeout(self.clear,0) def clear(self): self.view.erase_status('xmllint')