Distrotech / reportlab

Mirror of https://bitbucket.org/rptlab/reportlab
Other
61 stars 41 forks source link

findSpanStyle not implemented in this parser #28

Open venugopal24 opened 7 months ago

venugopal24 commented 7 months ago

Hello,Below is my question on reportlab

When i run the below code in py3 environment with reportlab version 4.0.0

from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet

sample_txt = '<p><span style=\'font-family: Arial; background-color: #ffffff;\'>Sample Content</span></p>'
styles = getSampleStyleSheet()
para_text = Paragraph(sample_txt, styles['Normal'])

Getting below error,

Traceback (most recent call last):
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3215, in parse
    self.feed(text)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 110, in feed
    self.goahead(0)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 170, in goahead
    k = self.parse_starttag(i)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 344, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3238, in handle_starttag
    start(attrs or {})
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 2832, in start_span
    style = self.findSpanStyle(A.pop('style'))
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3205, in findSpanStyle
    raise ValueError('findSpanStyle not implemented in this parser')
ValueError: findSpanStyle not implemented in this parser

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kvenugopal/venudocs/pypdfissue/reportlabone.py", line 6, in <module>
    para_text = Paragraph(sample_txt, styles['Normal'])
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paragraph.py", line 1800, in __init__
    self._setup(text, style, bulletText or getattr(style,'bulletText',None), frags, cleanBlockQuotedText)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paragraph.py", line 1821, in _setup
    style, frags, bulletTextFrags = _parser.parse(text,style)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3217, in parse
    annotateException('\nparagraph text %s caused exception' % ascii(text))
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/lib/utils.py", line 1176, in annotateException
    rl_reraise(t,t(sep.join((_ for _ in (msg,str(v),postMsg) if _))),b)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/lib/utils.py", line 138, in rl_reraise
    raise v.with_traceback(b)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3215, in parse
    self.feed(text)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 110, in feed
    self.goahead(0)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 170, in goahead
    k = self.parse_starttag(i)
  File "/home/kvenugopal/.pyenv/versions/3.9.7/lib/python3.9/html/parser.py", line 344, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3238, in handle_starttag
    start(attrs or {})
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 2832, in start_span
    style = self.findSpanStyle(A.pop('style'))
  File "/home/kvenugopal/venudocs/pypdfissue/reportlab/platypus/paraparser.py", line 3205, in findSpanStyle
    raise ValueError('findSpanStyle not implemented in this parser')
ValueError: 
paragraph text "<para><p><span style='font-family: Arial; background-color: #ffffff;'>Sample Content</span></p></para>" caused exception findSpanStyle not implemented in this parser

Any fix for the above issue?

venugopal24 commented 7 months ago

Any updates on this. I am seeing nothing from documentation as well