Skip to content

Commit

Permalink
Fix config on older ST3 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Aug 21, 2016
1 parent a620c3c commit f02540d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
3 changes: 1 addition & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ _Though I will not personally implement rules for your favorite language, I am m

2. When creating an issue on the repository, please provide as much info as possible:

- Sublime Text build.
- Operating system.
- Provide environment information by running `Preferences->Package Settings->ApplySyntax->Support Info`. The information will be copied to the clipboard; paste the info in issue.
- Errors in console.
- Detailed description of the problem.
- Examples for reproducing the error. You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# BracketHighlighter 2.21.4
> Released Aug 21, 2016
- **FIX**: Changelog command now works for older ST3 versions.

# BracketHighlighter 2.21.3
> Released Aug 1, 2016
Expand Down
4 changes: 2 additions & 2 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@
{ "caption": "-" },
{
"caption": "Changelog",
"command": "bh_changes"
"command": "bracket_highlighter_changes"
},
{ "caption": "-" },
{
"caption": "Support Info",
"command": "bh_support_info"
"command": "bracket_highlighter_support_info"
},
{ "caption": "-" }
]
Expand Down
34 changes: 20 additions & 14 deletions changes.py
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)
3 changes: 1 addition & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Contribution from the community is encouraged and can be done in a variety of wa

2. When creating an issue on the repository, please provide as much info as possible:

- Sublime Text build.
- Operating system.
- Provide environment information by running `Preferences->Package Settings->BracketHighlighter->Support Info`. The information will be copied to the clipboard; paste the info in issue.
- Errors in console.
- Detailed description of the problem.
- Examples for reproducing the error. You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.
Expand Down
24 changes: 12 additions & 12 deletions bh_support.py → support.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sublime_plugin
import textwrap

__version__ = "2.21.3"
__version__ = "2.21.4"
__pc_name__ = 'BracketHighlighter'


Expand Down Expand Up @@ -37,7 +37,7 @@ def is_installed_by_package_control():
return str(__pc_name__ in set(settings.get('installed_packages', [])))


class BhSupportInfoCommand(sublime_plugin.ApplicationCommand):
class BracketHighlighterSupportInfoCommand(sublime_plugin.ApplicationCommand):
"""Support info."""

def run(self):
Expand All @@ -48,7 +48,7 @@ def run(self):
info["platform"] = sublime.platform()
info["version"] = sublime.version()
info["arch"] = sublime.arch()
info["bh_version"] = __version__
info["plugin_version"] = __version__
info["pc_install"] = is_installed_by_package_control()
try:
import mdpopups
Expand Down Expand Up @@ -82,16 +82,16 @@ def run(self):

msg = textwrap.dedent(
"""\
- ST ver.: %(version)s
- Platform: %(platform)s
- Arch: %(arch)s
- Plugin ver.: %(bh_version)s
- ST ver.: %(version)s
- Platform: %(platform)s
- Arch: %(arch)s
- Plugin ver.: %(plugin_version)s
- Install via PC: %(pc_install)s
- mdpopups ver.: %(mdpopups_version)s
- backrefs ver.: %(backrefs_version)s
- markdown ver.: %(markdown_version)s
- pygments ver.: %(pygments_version)s
- jinja2 ver.: %(jinja_version)s
- mdpopups ver.: %(mdpopups_version)s
- backrefs ver.: %(backrefs_version)s
- markdown ver.: %(markdown_version)s
- pygments ver.: %(pygments_version)s
- jinja2 ver.: %(jinja_version)s
""" % info
)

Expand Down

0 comments on commit f02540d

Please sign in to comment.