Skip to content

Commit a581d60

Browse files
committed
Add background color for html output on Template
1 parent 4efe4fa commit a581d60

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/panela/panela_colors.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
There are several features that not yet implemented (see ___doc___ in Panela)
1313
1414
TODO:
15-
* html output
1615
* png output
1716
1817
"""
@@ -639,24 +638,26 @@ def parse(self):
639638

640639
def render_html(self, colorize=True):
641640

642-
prev_color = None
643-
prev_bg = None
641+
prev_style = (None, None)
644642

645643
for x, y, char, color, bg_color in self.data:
644+
style = (color, bg_color)
646645
if char == None: # end of line
647646
if colorize:
648-
if prev_color != None:
647+
if prev_style != (None, None):
649648
sys.stdout.write("</span>")
650-
prev_color = None
649+
prev_style = (None, None)
651650
sys.stdout.write("\n")
652651
else:
653652
if colorize:
654-
if color != prev_color:
655-
if prev_color != None:
653+
if style != prev_style:
654+
if prev_style != (None, None):
656655
sys.stdout.write("</span>")
657-
if color != None:
658-
sys.stdout.write("<span style=\"color: %s\">" % color)
659-
prev_color = color
656+
if style != (None, None):
657+
sys.stdout.write("<span style=\"" +
658+
"color: %s; " % style[0] +
659+
"background-color: %s\">" % style[1])
660+
prev_style = style
660661

661662
if char == '<':
662663
sys.stdout.write("&lt;")

0 commit comments

Comments
 (0)