Skip to content

Commit

Permalink
feat: pagination index
Browse files Browse the repository at this point in the history
Signed-off-by: 117503445 <[email protected]>
  • Loading branch information
117503445 committed Aug 23, 2023
1 parent b725b8c commit 37abe46
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/flow_pdf/flow_pdf/worker/html_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,23 @@ def mk_html(elements, dest: Path):
doc["elements"][i * PER_HTML_ELEMENTS : (i + 1) * PER_HTML_ELEMENTS],
doc_in.dir_output / "output" / f"part_{i}.html",
)

# make index
soup = BeautifulSoup(html, "html.parser")
# add version to head
for k, v in doc["meta"].items():
soup.html.head.append(soup.new_tag("meta", attrs={"name": k, "content": v})) # type: ignore

for i in range(0, int(len(doc["elements"]) / PER_HTML_ELEMENTS) + 1):
a = soup.new_tag(
"a", href=f"part_{i}.html", attrs={"class": "part-link"}
)
a.string = f"part_{i}"
soup.html.body.append(a) # type: ignore

soup.html.body.append(soup.new_tag("br")) # type: ignore

file.write_text(doc_in.dir_output / "output" / "index.html", soup.prettify())


return DocOutParams(), []

0 comments on commit 37abe46

Please sign in to comment.