我正在使用reportlab生成pdf文档。我正在使用以下标记:
<para><strong>Referred to MCH TVM.</strong></para><br/><para><i>Patient presented with bilateral neck nodes.</i></para><br/><para><i>O/E:</i></para><br/><para> Findings: klkllklklk</para><br/><para>Kindly advise.</para><br/>
我的代码包括:
regstyle = ParagraphStyle(
name='Regular', fontName='Helvetica', fontSize=10, leading=12)
AdviseBlock = Paragraph(f"{Advisedata}", style=regstyle)
这将产生以下错误:
2020-02-14 10:46:19,921 django.request ERROR Internal Server Error: /clinic/presc/hm9x9HHIRg
Traceback (most recent call last):
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/joel/myappointments/clinic/views.py", line 5886, in GoGetPrescription
clinicobj=clinicobj,
File "/home/joel/myappointments/clinic/views.py", line 13466, in PDFPrescriptions
elements = CreateAdvise(elements, cur_clinical_record)
File "/home/joel/myappointments/clinic/views.py", line 13421, in CreateAdvise
AdviseBlock = Paragraph(f"{Advisedata}", style=regstyle)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paragraph.py", line 1541, in __init__
self._setup(text, style, bulletText or getattr(style,'bulletText',None), frags, cleanBlockQuotedText)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paragraph.py", line 1563, in _setup
style, frags, bulletTextFrags = _parser.parse(text,style)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paraparser.py", line 3224, in parse
annotateException('\nparagraph text %s caused exception' % ascii(text))
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/lib/utils.py", line 1394, in annotateException
rl_reraise(t,v,b)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/lib/utils.py", line 147, in rl_reraise
raise v
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paraparser.py", line 3222, in parse
self.feed(text)
File "/usr/lib/python3.6/html/parser.py", line 111, in feed
self.goahead(0)
File "/usr/lib/python3.6/html/parser.py", line 171, in goahead
k = self.parse_starttag(i)
File "/usr/lib/python3.6/html/parser.py", line 343, in parse_starttag
self.handle_startendtag(tag, attrs)
File "/usr/lib/python3.6/html/parser.py", line 427, in handle_startendtag
self.handle_starttag(tag, attrs)
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paraparser.py", line 3245, in handle_starttag
start(attrs or {})
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paraparser.py", line 2861, in start_br
self._push('br',_selfClosingTag='br',lineBreak=True,text='')
File "/home/joel/myappointments/venv/lib/python3.6/site-packages/reportlab/platypus/paraparser.py", line 3063, in _push
frag = copy.copy(self._stack[-1])
IndexError: list index out of range
paragraph text '<para><strong>Referred to MCH TVM.</strong></para><br/><para><i>Patient presented with bilateral neck nodes.</i></para><br/><para><i>O/E:</i></para><br/><para> Findings: klkllklklk</para><br/><para>Kindly advise.</para><br/>' caused exception
我正在使用的标记出了什么问题?
整体可能被<para>
标签包围,但不必包含多次。
advise_data = '<para><strong>Referred to MCH TVM.</strong><br/><i>Patient presented with bilateral neck nodes.</i><br/><i>O/E:</i><br/>Findings: klkllklklk<br/>Kindly advise.</para>'