File tree 2 files changed +17
-4
lines changed 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 9
9
10
10
import sublime , sublime_plugin , re
11
11
12
+ settings = None
13
+ def plugin_loaded ():
14
+ global settings
15
+
16
+ # this file contains the tags that will be indented/unindented, etc.
17
+ settings = sublime .load_settings ('HTMLBeautify.sublime-settings' )
18
+
19
+ class PreSaveFormatListener (sublime_plugin .EventListener ):
20
+ """Event listener to run HtmlBeautify during the presave event"""
21
+ def on_pre_save (self , view ):
22
+ if settings .get ('format_on_save' ) and view .file_name ().lower ().endswith ('.html' ):
23
+ view .run_command ('html_beautify' )
24
+
12
25
class HtmlBeautifyCommand (sublime_plugin .TextCommand ):
13
26
def run (self , edit ):
14
27
15
- # this file contains the tags that will be indented/unindented, etc.
16
- settings = sublime .load_settings ('HTMLBeautify.sublime-settings' )
17
-
18
28
# the contents of these tags will not be indented
19
29
ignored_tag_opening = settings .get ('ignored_tag_opening' )
20
30
ignored_tag_closing = settings .get ('ignored_tag_closing' )
Original file line number Diff line number Diff line change 39
39
" </pre" ,
40
40
41
41
// set true to remove empty line
42
- "remove_extraline" : true
42
+ "remove_extraline" : true ,
43
+
44
+ // format on save
45
+ "format_on_save" : false
43
46
}
You can’t perform that action at this time.
0 commit comments