fix(api): Iterate over parts dict in PDF Template
This commit is contained in:
@@ -8,4 +8,5 @@ class StoryNotFoundError(WattpadError):
|
||||
...
|
||||
|
||||
|
||||
class PartNotFoundError(StoryNotFoundError): ...
|
||||
class PartNotFoundError(StoryNotFoundError):
|
||||
...
|
||||
|
||||
@@ -111,9 +111,9 @@ class PDFGenerator(AbstractGenerator):
|
||||
if not img_data:
|
||||
continue
|
||||
|
||||
img_tag["src"] = (
|
||||
f"data:image/jpg;base64,{b64encode(img_data).decode()}"
|
||||
)
|
||||
img_tag[
|
||||
"src"
|
||||
] = f"data:image/jpg;base64,{b64encode(img_data).decode()}"
|
||||
|
||||
data[part["id"]] = tree.prettify()
|
||||
|
||||
|
||||
@@ -46,13 +46,14 @@ id="copyright-license-image">
|
||||
<section id="contents" class="toc">
|
||||
<h1>Table of Contents</h1>
|
||||
<ul>
|
||||
{% for part_id in part_ids %}
|
||||
{% for part_id in parts %}
|
||||
<li><a href="#{{part_id}}"></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
{% for part_html in part_htmls %}
|
||||
{{part_html | safe}}
|
||||
{% for part_id in parts %}
|
||||
|
||||
{{parts[part_id] | safe}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ def clean_tree(title: str, id: int, body: str) -> BeautifulSoup:
|
||||
f"""
|
||||
<h1 class="chapter-name" id={id}>{title}</h1>
|
||||
<section class="chapter-body"></section>
|
||||
"""
|
||||
""",
|
||||
parser="html.parser", # head/body tags aren't generated
|
||||
)
|
||||
|
||||
insert_at = cast(Tag, new_soup.find("section"))
|
||||
|
||||
Reference in New Issue
Block a user