Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 682fb4da89 |
+30
-24
@@ -133,7 +133,7 @@ def generate_clean_part_html(part: Part, content: str) -> bs4.Tag:
|
|||||||
|
|
||||||
clean = BeautifulSoup(
|
clean = BeautifulSoup(
|
||||||
f"""
|
f"""
|
||||||
<section id="section_{chapter_id}">
|
<section id="section_{chapter_id}" class="chapitre">
|
||||||
<h1 id="{chapter_id}" class="chapter-title">{chapter_title}</h1>
|
<h1 id="{chapter_id}" class="chapter-title">{chapter_title}</h1>
|
||||||
</section>
|
</section>
|
||||||
""",
|
""",
|
||||||
@@ -151,14 +151,6 @@ def generate_clean_part_html(part: Part, content: str) -> bs4.Tag:
|
|||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
for child in html.find_all("p"):
|
for child in html.find_all("p"):
|
||||||
current_paragraph = clean.new_tag("p")
|
|
||||||
|
|
||||||
# Attempt to carry over paragraph styling
|
|
||||||
try:
|
|
||||||
current_paragraph["style"] = child["style"]
|
|
||||||
except:
|
|
||||||
current_paragraph["style"] = "text-align: left;"
|
|
||||||
|
|
||||||
for p_child in list(child.children):
|
for p_child in list(child.children):
|
||||||
if not p_child:
|
if not p_child:
|
||||||
continue
|
continue
|
||||||
@@ -169,22 +161,37 @@ def generate_clean_part_html(part: Part, content: str) -> bs4.Tag:
|
|||||||
src = p_child["src"]
|
src = p_child["src"]
|
||||||
img_tag = clean.new_tag("img")
|
img_tag = clean.new_tag("img")
|
||||||
img_tag["src"] = src
|
img_tag["src"] = src
|
||||||
|
break_tag = clean.new_tag("br")
|
||||||
section.append(img_tag)
|
section.append(img_tag)
|
||||||
section.append(clean.new_tag("br"))
|
section.append(break_tag)
|
||||||
elif p_child.name in ["b", "i"]:
|
elif p_child.name == "b":
|
||||||
styled_tag = clean.new_tag(p_child.name)
|
content = p_child.text
|
||||||
styled_content = clean.new_string(p_child.text)
|
p_tag = clean.new_tag("p")
|
||||||
styled_tag.append(styled_content)
|
bold_tag = clean.new_tag("b")
|
||||||
current_paragraph.append(styled_tag)
|
bold_content = clean.new_string(content)
|
||||||
else:
|
|
||||||
# Append any other tags as-is
|
|
||||||
current_paragraph.append(p_child)
|
|
||||||
elif isinstance(p_child, bs4.element.NavigableString):
|
|
||||||
content = clean.new_string(p_child)
|
|
||||||
current_paragraph.append(content)
|
|
||||||
|
|
||||||
if current_paragraph.contents:
|
bold_tag.append(bold_content)
|
||||||
section.append(current_paragraph)
|
p_tag.append(bold_tag)
|
||||||
|
|
||||||
|
section.append(p_tag)
|
||||||
|
|
||||||
|
elif p_child.name == "i":
|
||||||
|
content = p_child.text
|
||||||
|
p_tag = clean.new_tag("p")
|
||||||
|
italic_tag = clean.new_tag("i")
|
||||||
|
italic_content = clean.new_string(content)
|
||||||
|
|
||||||
|
italic_tag.append(italic_content)
|
||||||
|
p_tag.append(italic_tag)
|
||||||
|
|
||||||
|
section.append(p_tag)
|
||||||
|
|
||||||
|
elif isinstance(p_child, bs4.element.NavigableString):
|
||||||
|
content = p_child.text
|
||||||
|
p_tag = clean.new_tag("p")
|
||||||
|
p_content = clean.new_string(content)
|
||||||
|
p_tag.append(p_content)
|
||||||
|
section.append(p_tag)
|
||||||
|
|
||||||
if not list(child.children):
|
if not list(child.children):
|
||||||
# Some p tags only contain brs, once brs are removed, they are empty and can be removed as well.
|
# Some p tags only contain brs, once brs are removed, they are empty and can be removed as well.
|
||||||
@@ -454,7 +461,6 @@ class EPUBGenerator:
|
|||||||
|
|
||||||
for cidx, (part, content) in enumerate(zip(self.data["parts"], contents)):
|
for cidx, (part, content) in enumerate(zip(self.data["parts"], contents)):
|
||||||
title = part["title"]
|
title = part["title"]
|
||||||
title = re.sub(r'[\x00-\x1F\x7F]', '', title) # Remove control characters
|
|
||||||
|
|
||||||
# Thanks https://eu17.proxysite.com/process.php?d=5VyWYcoQl%2BVF0BYOuOavtvjOloFUZz2BJ%2Fepiusk6Nz7PV%2B9i8rs7cFviGftrBNll%2B0a3qO7UiDkTt4qwCa0fDES&b=1
|
# Thanks https://eu17.proxysite.com/process.php?d=5VyWYcoQl%2BVF0BYOuOavtvjOloFUZz2BJ%2Fepiusk6Nz7PV%2B9i8rs7cFviGftrBNll%2B0a3qO7UiDkTt4qwCa0fDES&b=1
|
||||||
chapter = epub.EpubHtml(
|
chapter = epub.EpubHtml(
|
||||||
|
|||||||
@@ -205,8 +205,6 @@ section {
|
|||||||
#contents a {
|
#contents a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
}
|
||||||
#contents a::before {
|
#contents a::before {
|
||||||
content: target-counter(attr(href), h2-counter) '. ' target-text(attr(href));
|
content: target-counter(attr(href), h2-counter) '. ' target-text(attr(href));
|
||||||
|
|||||||
@@ -95,6 +95,30 @@
|
|||||||
>
|
>
|
||||||
Wattpad Downloader
|
Wattpad Downloader
|
||||||
</h1>
|
</h1>
|
||||||
|
<div
|
||||||
|
role="alert"
|
||||||
|
class="alert bg-amber-200 mt-10 break-words max-w-md"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
class="h-6 w-6 shrink-0 stroke-current"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Hey everyone, have a great new year! You're now on the Donator
|
||||||
|
version for a few days :)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- <div role="alert" class="alert bg-cyan-300 mt-5">
|
<!-- <div role="alert" class="alert bg-cyan-300 mt-5">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|||||||
Reference in New Issue
Block a user