-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18cc48a
commit 8a3e562
Showing
4 changed files
with
113 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"caption": "Tag: Get CSS Classes", | ||
"command": "tag_classes" | ||
} | ||
] |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sublime, sublime_plugin | ||
import re | ||
|
||
class TagClassesCommand(sublime_plugin.TextCommand): | ||
def run(self, edit): | ||
data = '' | ||
classes = [] | ||
for region in self.view.sel(): | ||
if region.empty(): | ||
continue | ||
data += self.view.substr(sublime.Region(region.begin(), region.end())) | ||
|
||
if not data: | ||
data += self.view.substr(sublime.Region(0, self.view.size())) | ||
|
||
if data: | ||
re_classes = (" ".join(re.compile('class="([^"]+)"').findall(data))).split() | ||
for item in re_classes: | ||
item = item.strip() | ||
if '.'+item+' {}' not in classes: | ||
classes.append('.'+item+' {}') | ||
if classes: | ||
s = sublime.load_settings('Tag Package.sublime-settings') | ||
if s.get('tag_classes_sort', False): | ||
classes.sort() | ||
sublime.set_clipboard("\n".join(classes)) | ||
sublime.status_message("CSS Classes Copied to Clipboard") | ||
|
||
|