[FIX] report: line splitting compatible with reportlab > 3.0
While keeping the compatibility for reportlab 2.5. Splitting the text node on line breaks '\n' leaded to orphans ending tags, like '</font>', which is regarded by reportlab 3.0 as a paragraph, and reportlab therefore surrounded these tags by <para> tags, which leaded to not syntax correct html like <para></font></para> To test this patch: - While having reportlab > 3.0 - Create a rml report containing (at least) '<font>\n</font>' - Then print the report. It must not crash (obviously)
This commit is contained in:
parent
d5c7234474
commit
c62a75a5f3
|
@ -768,15 +768,10 @@ class _rml_flowable(object):
|
|||
style = self.styles.para_style_get(node)
|
||||
if extra_style:
|
||||
style.__dict__.update(extra_style)
|
||||
result = []
|
||||
tag_text = ''
|
||||
plain_text = ''
|
||||
for i in self._textual(node).split('\n'):
|
||||
instance = platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'})))
|
||||
plain_text += instance.getPlainText().strip()
|
||||
tag_text += instance.text.strip()
|
||||
result.append(instance)
|
||||
if LooseVersion(reportlab.Version) > LooseVersion('3.0') and not plain_text and tag_text:
|
||||
text_node = self._textual(node).strip().replace('\n\n', '\n').replace('\n', '<br/>')
|
||||
instance = platypus.Paragraph(text_node, style, **(utils.attr_get(node, [], {'bulletText':'str'})))
|
||||
result = [instance]
|
||||
if LooseVersion(reportlab.Version) > LooseVersion('3.0') and not instance.getPlainText().strip() and instance.text.strip():
|
||||
result.append(platypus.Paragraph(' <br/>', style, **(utils.attr_get(node, [], {'bulletText': 'str'}))))
|
||||
return result
|
||||
elif node.tag=='barCode':
|
||||
|
|
Loading…
Reference in New Issue