Skip to content

Commit

Permalink
Reload CSS when highlighter option changes.
Browse files Browse the repository at this point in the history
CSS wasn't getting refreshed when the use of pygments and ST highlighter
setting was changed.
  • Loading branch information
facelessuser committed Nov 13, 2015
1 parent ca06091 commit ba19dca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion st3/mdpopups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@ def _get_scheme_css(view, css):
if not in cache or entry is expired in cache.
"""
scheme = view.settings().get('color_scheme')
settings = sublime.load_settings("Preferences.sublime-settings")
obj = None
user_css = ''
if scheme is not None:
if scheme in _scheme_cache:
obj, user_css, t = _scheme_cache[scheme]
if is_cache_expired(t):
# Check if cache expired or user changed pygments setting.
if (
is_cache_expired(t) or
obj.variables.get('use_pygments', True) != (not settings.get('mdpopups.use_sublime_highlighter', False))
):
obj = None
user_css = ''
if obj is None:
Expand Down
12 changes: 6 additions & 6 deletions st3/mdpopups/st_scheme_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def parse_global(self):
self.variables = {
"is_dark": is_dark,
"is_light": not is_dark,
"color_scheme": self.scheme_file
"color_scheme": self.scheme_file,
"use_pygments": not sublime.load_settings("Preferences.sublime-settings").get(
'mdpopups.use_sublime_highlighter', False
)
}
self.html_border = rgba.get_rgb()
self.fground = self.strip_color(color_settings.get("foreground", '#000000'))
Expand Down Expand Up @@ -322,11 +325,8 @@ def retrieve_selector(self, selector, key=None):

def apply_template(self, css):
"""Apply template to css."""
var = copy.copy(self.variables)
var['use_pygments'] = not sublime.load_settings("Preferences.sublime-settings").get(
'mdpopups.use_sublime_highlighter', False
)
return self.env.from_string(css).render(var=var, colors=self.colors)

return self.env.from_string(css).render(var=copy.copy(self.variables), colors=self.colors)

def get_css(self):
"""Get css."""
Expand Down

0 comments on commit ba19dca

Please sign in to comment.