summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-03-08 15:08:19 +0100
committerGeorg Brandl <georg@python.org>2015-03-08 15:08:19 +0100
commit03e8b0488d50f498750d4c025614487cf34d5c92 (patch)
tree2fecc7264140cd0b893eb27b1b67d961c0378bca
parent98a654a135e4d6f65d03ffae12ebb24afb78f3ee (diff)
downloadpygments-03e8b0488d50f498750d4c025614487cf34d5c92.tar.gz
Fixed style inheritance for non-standard token types in HTML output.
-rw-r--r--CHANGES2
-rw-r--r--pygments/formatters/html.py11
-rw-r--r--pygments/style.py2
3 files changed, 13 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 33034ba2..ad5bba49 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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][:]