Skip to content

Commit

Permalink
fix: Fix changelog visual glitches
Browse files Browse the repository at this point in the history
  • Loading branch information
equinusocio committed Aug 4, 2016
1 parent 6318104 commit cdfe22f
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions mt_changes.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
"""Changelog."""
# -*- coding: utf-8 -*-

"""
Material Theme Changelog
"""

import sublime
import sublime_plugin

CSS = '''
.mt-config-changes { {{'.background'|css}} margin: 0; padding: 0; }
.mt-config-changes ul li, .bracket-hightlighter p { {{'.foreground'|css}} }
.mt-config-changes a { color: #4B67FF; }
.mt-config-changes h1, .mt-config-changes h2, .mt-config-changes h3,
.mt-config-changes h4, .mt-config-changes h5, .mt-config-changes h6 {
{{'.string'|css('color')}}
STYLES = '''
.mdpopups {
{{'.background'|css}}
}
.mt-config-changes ul li, .mt-config-changes p {
{{'.foreground'|css}}
}
.mt-config-changes a {
text-decoration: none;
color: #6D88FF;
}
.mt-config-changes h1, .mt-config-changes h2 { margin-top: 50px; }
.mt-config-changes h3, .mt-config-changes h4 { margin-top: 30px; }
.mt-config-changes blockquote { {{'.foreground'|css('color')}} }
'''
.mt-config-changes h1,
.mt-config-changes h2,
.mt-config-changes h3,
.mt-config-changes h4,
.mt-config-changes h5,
.mt-config-changes h6 {
{{'.string'|css('color')}}
}
.mt-config-changes h1,
.mt-config-changes h2 {
margin-top: 50px;
}
.mt-config-changes h3,
.mt-config-changes h4 {
margin-top: 30px;
}
'''

class MtChangesCommand(sublime_plugin.WindowCommand):
"""Changelog command."""

def run(self):
"""Show the changelog in a new view."""
import mdpopups
text = sublime.load_resource('Packages/Material Theme/CHANGELOG.md')
view = self.window.new_file()
view.set_name('Material Theme - Changelog')
view.set_name('Material Theme Changelog')
view.settings().set('gutter', False)
html = '<div class="mt-config-changes">%s</div>' % mdpopups.md2html(view, text)
mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=CSS)
mdpopups.add_phantom(view, 'changelog', sublime.Region(0), html, sublime.LAYOUT_INLINE, css=STYLES)
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
is_visible = is_enabled

0 comments on commit cdfe22f

Please sign in to comment.