diff options
author | Georg Brandl <georg@python.org> | 2015-03-08 15:11:49 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2015-03-08 15:11:49 +0100 |
commit | 97040aba135480f60262d944cf2649f59b63f3de (patch) | |
tree | 617afd629eb3b6991522f5e02579303982d3c53f | |
parent | e871b16968f56234daa21947598e89638279c9a1 (diff) | |
parent | 03e8b0488d50f498750d4c025614487cf34d5c92 (diff) | |
download | pygments-97040aba135480f60262d944cf2649f59b63f3de.tar.gz |
Merged in miikkas/pygments-py3stringinterpolation (pull request #455)
String interpolation support for Python 3
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/formatters/html.py | 11 | ||||
-rw-r--r-- | pygments/style.py | 2 |
3 files changed, 13 insertions, 2 deletions
@@ -24,6 +24,8 @@ Version 2.1 - Updated autopygmentize script (PR#445) +- Fixed style inheritance for non-standard token types in HTML output. + Version 2.0.3 ------------- diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 55548d30..67ad685f 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -428,6 +428,15 @@ class HtmlFormatter(Formatter): return self.classprefix + ttypeclass return '' + def _get_css_classes(self, ttype): + """Return the css classes of this token type prefixed with + the classprefix option.""" + cls = self._get_css_class(ttype) + while ttype not in STANDARD_TYPES: + ttype = ttype.parent + cls = self._get_css_class(ttype) + ' ' + cls + return cls + def _create_stylesheet(self): t2c = self.ttype2class = {Token: ''} c2s = self.class2style = {} @@ -711,7 +720,7 @@ class HtmlFormatter(Formatter): cclass = getcls(ttype) cspan = cclass and '<span style="%s">' % c2s[cclass][0] or '' else: - cls = self._get_css_class(ttype) + cls = self._get_css_classes(ttype) cspan = cls and '<span class="%s">' % cls or '' parts = value.translate(escape_table).split('\n') diff --git a/pygments/style.py b/pygments/style.py index a49e9b7e..b2b990ea 100644 --- a/pygments/style.py +++ b/pygments/style.py @@ -40,7 +40,7 @@ class StyleMeta(type): continue ndef = _styles.get(token.parent, None) styledefs = obj.styles.get(token, '').split() - if not ndef or token is None: + if not ndef or token is None: ndef = ['', 0, 0, 0, '', '', 0, 0, 0] elif 'noinherit' in styledefs and token is not Token: ndef = _styles[Token][:] |