parent
74bf3b58f9
commit
5bac8ec1e4
@ -157,25 +157,25 @@ def convert_html_to_reportlab(pdf, text):
|
|||||||
for element in soup.find_all('li'):
|
for element in soup.find_all('li'):
|
||||||
# ... and replace ul list elements with <para><bullet>•</bullet>...<para>
|
# ... and replace ul list elements with <para><bullet>•</bullet>...<para>
|
||||||
if element.parent.name == "ul":
|
if element.parent.name == "ul":
|
||||||
if element.ul:
|
# nested lists
|
||||||
# for nested ul lists use simple spaces (pragmatic solution)
|
if element.ul or element.ol:
|
||||||
element.li.insert(0, ' ')
|
for i in element.find_all('li'):
|
||||||
element.insert_before(element.find_all('li'))
|
element.insert_before(i)
|
||||||
element.clear()
|
element.clear()
|
||||||
else:
|
else:
|
||||||
element.name = "para"
|
element.name = "para"
|
||||||
bullet_tag = soup.new_tag("bullet")
|
bullet_tag = soup.new_tag("bullet")
|
||||||
bullet_tag.string = "•"
|
bullet_tag.string = u"•"
|
||||||
element.insert(0, bullet_tag)
|
element.insert(0, bullet_tag)
|
||||||
# ... and replace ol list elements with <para><bullet><seq id="%id"></seq>.</bullet>...</para>
|
# ... and replace ol list elements with <para><bullet><seq id="%id"></seq>.</bullet>...</para>
|
||||||
if element.parent.name == "ol":
|
if element.parent.name == "ol":
|
||||||
# set list id if element is the first of numbered list
|
# set list id if element is the first of numbered list
|
||||||
if not element.find_previous_sibling():
|
if not element.find_previous_sibling():
|
||||||
id = random.randrange(0, 101)
|
id = random.randrange(0, 101)
|
||||||
if element.ol:
|
# nested lists
|
||||||
# nested ol list
|
if element.ul or element.ol:
|
||||||
element.li.insert(0, ' ')
|
for i in element.find_all('li'):
|
||||||
element.insert_before(element.find_all('li'))
|
element.insert_before(i)
|
||||||
element.clear()
|
element.clear()
|
||||||
else:
|
else:
|
||||||
element.name = "para"
|
element.name = "para"
|
||||||
|
Loading…
Reference in New Issue
Block a user