Skip to content

Commit

Permalink
Fix for cssAttr is list and lower()
Browse files Browse the repository at this point in the history
  • Loading branch information
sbywater committed Jan 15, 2015
1 parent a93c5bd commit 777846a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions xhtml2pdf/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ def CSSCollect(node, c):

return node.cssAttrs

def lower(sequence):
if sequence in types.StringTypes:
return sequence.lower()
else:
return sequence[0].lower()

def CSS2Frag(c, kw, isBlock):
# COLORS
if "color" in c.cssAttr:
Expand All @@ -289,7 +295,7 @@ def CSS2Frag(c, kw, isBlock):
c.frag.leadingSpace = getSize("".join(c.cssAttr["-pdf-line-spacing"]))
# print "line-spacing", c.cssAttr["-pdf-line-spacing"], c.frag.leading
if "font-weight" in c.cssAttr:
value = c.cssAttr["font-weight"].lower()
value = lower(c.cssAttr["font-weight"])
if value in ("bold", "bolder", "500", "600", "700", "800", "900"):
c.frag.bold = 1
else:
Expand All @@ -303,7 +309,7 @@ def CSS2Frag(c, kw, isBlock):
c.frag.underline = 0
c.frag.strike = 0
if "font-style" in c.cssAttr:
value = c.cssAttr["font-style"].lower()
value = lower(c.cssAttr["font-style"])
if value in ("italic", "oblique"):
c.frag.italic = 1
else:
Expand Down Expand Up @@ -476,9 +482,7 @@ def pisaLoop(node, context, path=None, **kw):

pageBreakAfter = False
frameBreakAfter = False
display = context.cssAttr.get("display", "inline")
if hasattr(display, 'lower'):
display = display.lower()
display = lower(context.cssAttr.get("display", "inline"))
# print indent, node.tagName, display, context.cssAttr.get("background-color", None), attr
isBlock = (display == "block")

Expand Down

0 comments on commit 777846a

Please sign in to comment.