-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
a620c3c
commit f02540d
Showing
6 changed files
with
41 additions
and
32 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
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 |
---|---|---|
@@ -1,39 +1,45 @@ | ||
"""Changelog.""" | ||
import sublime | ||
import sublime_plugin | ||
import webbrowser | ||
|
||
CSS = ''' | ||
html { {{'.background'|css}} } | ||
div.bracket-highlighter { padding: 0; margin: 0; {{'.background'|css}} } | ||
.bracket-highlighter h1, .bracket-highlighter h2, .bracket-highlighter h3, | ||
.bracket-highlighter h4, .bracket-highlighter h5, .bracket-highlighter h6 { | ||
{{'.string'|css('color')}} | ||
} | ||
.bracket-highlighter blockquote { {{'.comment'|css('color')}} } | ||
.apply-syntax a { text-decoration: none; } | ||
''' | ||
|
||
|
||
class BhChangesCommand(sublime_plugin.WindowCommand): | ||
class BracketHighlighterChangesCommand(sublime_plugin.WindowCommand): | ||
"""Changelog command.""" | ||
|
||
def run(self): | ||
"""Show the changelog in a new view.""" | ||
import mdpopups | ||
try: | ||
import mdpopups | ||
has_phantom_support = (mdpopups.version() >= (1, 7, 3)) and (int(sublime.version()) >= 3118) | ||
except Exception: | ||
has_phantom_support = False | ||
|
||
text = sublime.load_resource('Packages/BracketHighlighter/CHANGES.md') | ||
view = self.window.new_file() | ||
view.set_name('BracketHighlighter - Changelog') | ||
view.settings().set('gutter', False) | ||
html = '<div class="bracket-highlighter">%s</div>' % mdpopups.md2html(view, text) | ||
mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=CSS) | ||
if has_phantom_support: | ||
html = '<div class="bracket-highlighter">%s</div>' % mdpopups.md2html(view, text) | ||
mdpopups.add_phantom( | ||
view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=CSS, on_navigate=self.on_navigate | ||
) | ||
else: | ||
view.run_command('insert', {"characters": text}) | ||
view.set_read_only(True) | ||
view.set_scratch(True) | ||
|
||
def is_enabled(self): | ||
"""Check if is enabled.""" | ||
try: | ||
import mdpopups | ||
except Exception: | ||
return False | ||
|
||
return (mdpopups.version() >= (1, 7, 3)) and (int(sublime.version()) >= 3118) | ||
|
||
is_visible = is_enabled | ||
def on_navigate(self, href): | ||
"""Open links.""" | ||
webbrowser.open_new_tab(href) |
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