Skip to content

Commit 68bb346

Browse files
committed
Improve markdown formating
1 parent 22b6dbe commit 68bb346

File tree

7 files changed

+29
-13
lines changed

7 files changed

+29
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# epub2txt
22

3-
**epub2txt** is a robust, efficient Python script to convert EPUB files to clean, readable, and LLM-friendly plain text (TXT).
3+
**epub2txt** is a robust, efficient Python script to convert EPUB files to clean, readable, and LLM-friendly plain text.
44

5-
**epub2txt** は、EPUB ファイルをクリーンで読みやすく、LLMにも適したプレーンテキスト (TXT) に変換する、堅牢で効率的な Python スクリプトです。
5+
**epub2txt** は、EPUB ファイルをクリーンで読みやすく、LLMにも適したプレーンテキストに変換する、堅牢で効率的な Python スクリプトです。
66

7-
**epub2txt** 是一個強大且高效的 Python 腳本,用於將 EPUB 檔案轉換為清晰易讀且適合 LLM 使用的純文字 (TXT)
7+
**epub2txt** 是一個強大且高效的 Python 腳本,用於將 EPUB 檔案轉換為清晰易讀且適合 LLM 使用的純文字。
88

99
<br>
1010

app/epub2txt.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,14 @@ document.addEventListener('DOMContentLoaded', () => {
699699
return;
700700
}
701701

702+
// Handle Bold
703+
if (tagName === 'B' || tagName === 'STRONG') {
704+
if (!inPre) pushSegment("**", false);
705+
collectTextSegments(node, inPre, segments, state, listDepth);
706+
if (!inPre) pushSegment("**", false);
707+
return;
708+
}
709+
702710
// Handle Lists
703711
if (tagName === 'UL' || tagName === 'OL') {
704712
if (!inPre) pushSegment("\n", false);
@@ -710,7 +718,7 @@ document.addEventListener('DOMContentLoaded', () => {
710718
if (tagName === 'LI') {
711719
if (!inPre) {
712720
pushSegment("\n", false);
713-
const indent = " ".repeat(Math.max(0, listDepth - 1));
721+
const indent = " ".repeat(Math.max(0, listDepth - 1));
714722
pushSegment(indent + "- ", true);
715723
}
716724
collectTextSegments(node, inPre, segments, state, listDepth);

css/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ header {
9696
}
9797

9898
.hero h1 {
99-
font-size: 3.25rem;
99+
font-size: 3rem;
100100
font-weight: 800;
101101
line-height: 1.1;
102102
margin-bottom: 24px;
@@ -270,7 +270,7 @@ footer a:hover {
270270

271271
@media (max-width: 768px) {
272272
.hero h1 {
273-
font-size: 2.25rem;
273+
font-size: 2.125rem;
274274
}
275275

276276
.hero p {

epub2txt.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,14 @@ def walk(node, in_pre: bool = False, list_depth: int = 0):
528528
add_text("\n", in_pre)
529529
continue
530530

531+
if name in ('b', 'strong'):
532+
if not in_pre:
533+
add_text("**", False)
534+
walk(child, in_pre, list_depth)
535+
if not in_pre:
536+
add_text("**", False)
537+
continue
538+
531539
# Handle Lists
532540
if name in ('ul', 'ol'):
533541
if not in_pre:
@@ -541,7 +549,7 @@ def walk(node, in_pre: bool = False, list_depth: int = 0):
541549
if not in_pre:
542550
add_text("\n", False)
543551
# Indent based on depth (depth 1 = no indent, depth 2 = 2 spaces, etc.)
544-
indent = " " * max(0, list_depth - 1)
552+
indent = " " * max(0, list_depth - 1)
545553
add_text(indent + "- ", True)
546554
walk(child, in_pre, list_depth)
547555
if not in_pre:

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<section class="hero">
6666
<h1>Convert EPUB to Text<br>Efficiently using epub2txt</h1>
67-
<p>A powerful, open-source Python script to batch convert your EPUB files into clean, readable, and LLM-ready plain text (TXT).</p>
67+
<p>A powerful open-source Python script that converts EPUBs into clean, Markdown-compatible text ideal for LLMs.</p>
6868
<div class="hero-buttons">
6969
<a href="https://github.com/SPACESODA/epub2txt" class="cta-button primary" data-umami-event="epub | Get Script Button">Get the Script</a>
7070
<a href="#app" class="cta-button secondary" data-umami-event="epub | Go to Converter Button">Convert Online</a>
@@ -143,7 +143,7 @@ <h2 id="success-filename">book.txt</h2>
143143
<footer>
144144
<div class="container">
145145
<p>&copy; SPACESODA / ANTHONYC<br>Released under the MIT License.</p>
146-
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> Star on GitHub</a></p>
146+
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> Star on GitHub</a></p>
147147
</div>
148148
</footer>
149149

ja/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<section class="hero">
6666
<h1>epub2txt で<br>EPUBをテキストに効率よく変換</h1>
67-
<p>EPUBファイルを一括で、読みやすく整えられたLLMにも適したプレーンテキスト(TXT)に変換する、強力なオープンソースPythonスクリプト</p>
67+
<p>EPUBをMarkdown互換テキストに変換し、LLMにも最適な出力が得られる強力なオープンソースのPythonスクリプトです</p>
6868
<div class="hero-buttons">
6969
<a href="https://github.com/SPACESODA/epub2txt" class="cta-button primary" data-umami-event="epub | Get Script Button">スクリプトを入手</a>
7070
<a href="#app" class="cta-button secondary" data-umami-event="epub | Go to Converter Button">オンラインで変換</a>
@@ -143,7 +143,7 @@ <h2 id="success-filename">book.txt</h2>
143143
<footer>
144144
<div class="container">
145145
<p>&copy; SPACESODA / ANTHONYC<br>Released under the MIT License.</p>
146-
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> GitHubでスターしてね</a></p>
146+
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> GitHubでスターしてね</a></p>
147147
</div>
148148
</footer>
149149

zh/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<section class="hero">
6666
<h1>使用 epub2txt<br>將 EPUB 高效地轉為純文字</h1>
67-
<p>這是一個強大的開源 Python 腳本,可將整個電子書庫批量轉換為清晰、易讀且適合 LLM 使用的純文字 (TXT)</p>
67+
<p>強大的開源 Python 腳本,可將 EPUB 轉成乾淨、與 Markdown 相容的文字,特別適合 LLM 使用</p>
6868
<div class="hero-buttons">
6969
<a href="https://github.com/SPACESODA/epub2txt" class="cta-button primary" data-umami-event="epub | Get Script Button">前往腳本</a>
7070
<a href="#app" class="cta-button secondary" data-umami-event="epub | Go to Converter Button">線上轉換</a>
@@ -143,7 +143,7 @@ <h2 id="success-filename">book.txt</h2>
143143
<footer>
144144
<div class="container">
145145
<p>&copy; SPACESODA / ANTHONYC<br>Released under the MIT License.</p>
146-
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> 在 GitHub 給個星吧</a></p>
146+
<p class="footer-github"><a href="https://github.com/SPACESODA/epub2txt" target="_blank" rel="noopener"> 在 GitHub 給個星吧</a></p>
147147
</div>
148148
</footer>
149149

0 commit comments

Comments
 (0)