summaryrefslogtreecommitdiff
path: root/pygments/formatters/html.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/formatters/html.py')
-rw-r--r--pygments/formatters/html.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index 7d7605eb..bbddf507 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -41,6 +41,11 @@ def escape_html(text, table=_escape_html_table):
"""Escape &, <, > as well as single and double quotes for HTML."""
return text.translate(table)
+def webify(color):
+ if color.startswith('calc') or color.startswith('var'):
+ return color
+ else:
+ return '#' + color
def _get_ttype_class(ttype):
fname = STANDARD_TYPES.get(ttype)
@@ -451,7 +456,7 @@ class HtmlFormatter(Formatter):
name = self._get_css_class(ttype)
style = ''
if ndef['color']:
- style += 'color: #%s; ' % ndef['color']
+ style += 'color: %s; ' % webify(ndef['color'])
if ndef['bold']:
style += 'font-weight: bold; '
if ndef['italic']:
@@ -459,9 +464,9 @@ class HtmlFormatter(Formatter):
if ndef['underline']:
style += 'text-decoration: underline; '
if ndef['bgcolor']:
- style += 'background-color: #%s; ' % ndef['bgcolor']
+ style += 'background-color: %s; ' % webify(ndef['bgcolor'])
if ndef['border']:
- style += 'border: 1px solid #%s; ' % ndef['border']
+ style += 'border: 1px solid %s; ' % webify(ndef['border'])
if style:
t2c[ttype] = name
# save len(ttype) to enable ordering the styles by