txt2ebook 0.1.145__py3-none-any.whl → 0.1.146__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- txt2ebook/languages/en.py +3 -2
- txt2ebook/subcommands/massage.py +40 -12
- {txt2ebook-0.1.145.dist-info → txt2ebook-0.1.146.dist-info}/METADATA +7 -13
- {txt2ebook-0.1.145.dist-info → txt2ebook-0.1.146.dist-info}/RECORD +7 -7
- {txt2ebook-0.1.145.dist-info → txt2ebook-0.1.146.dist-info}/WHEEL +0 -0
- {txt2ebook-0.1.145.dist-info → txt2ebook-0.1.146.dist-info}/entry_points.txt +0 -0
- {txt2ebook-0.1.145.dist-info → txt2ebook-0.1.146.dist-info}/licenses/LICENSE.md +0 -0
txt2ebook/languages/en.py
CHANGED
@@ -17,7 +17,8 @@
|
|
17
17
|
|
18
18
|
DEFAULT_RE_TITLE = r"Title:(.*)"
|
19
19
|
DEFAULT_RE_AUTHOR = r"Author:(.*)"
|
20
|
-
DEFAULT_RE_TAG = r"Tags
|
21
|
-
DEFAULT_RE_INDEX = r"Index
|
20
|
+
DEFAULT_RE_TAG = r"Tags:(.*)"
|
21
|
+
DEFAULT_RE_INDEX = r"Index:(.*)"
|
22
22
|
DEFAULT_RE_VOLUME = r"(Volume.*)"
|
23
23
|
DEFAULT_RE_CHAPTER = r"(Chapter.*)"
|
24
|
+
DEFAULT_RE_TRANSLATOR = r"Translator:(.*)"
|
txt2ebook/subcommands/massage.py
CHANGED
@@ -19,6 +19,7 @@ import argparse
|
|
19
19
|
import logging
|
20
20
|
import sys
|
21
21
|
from importlib import import_module
|
22
|
+
from pathlib import Path
|
22
23
|
|
23
24
|
import cjkwrap
|
24
25
|
import regex as re
|
@@ -201,21 +202,48 @@ def run(args: argparse.Namespace) -> None:
|
|
201
202
|
None
|
202
203
|
"""
|
203
204
|
massaged_txt = massage_txt(args)
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
205
|
+
if args.overwrite:
|
206
|
+
_overwrite_file(args, massaged_txt)
|
207
|
+
else:
|
208
|
+
_new_file(args, massaged_txt)
|
209
|
+
|
210
|
+
# args.language = detect_and_expect_language(massaged_txt, args.language)
|
211
|
+
# config_lang = args.language.replace("-", "_")
|
212
|
+
# langconf = import_module(f"txt2ebook.languages.{config_lang}")
|
213
|
+
# args.with_toc = False
|
214
|
+
# parser = Parser(massaged_txt, args, langconf)
|
215
|
+
# book = parser.parse()
|
216
|
+
|
217
|
+
# if args.debug:
|
218
|
+
# book.debug(args.verbose)
|
219
|
+
|
220
|
+
# if args.header_number:
|
221
|
+
# book = header_number(args, book)
|
222
|
+
|
223
|
+
# writer = TxtWriter(book, args)
|
224
|
+
# writer.write()
|
210
225
|
|
211
|
-
if args.debug:
|
212
|
-
book.debug(args.verbose)
|
213
226
|
|
214
|
-
|
215
|
-
|
227
|
+
def _overwrite_file(args, massaged_txt) -> None:
|
228
|
+
txt_filename = Path(args.input_file.name)
|
229
|
+
|
230
|
+
with open(txt_filename, "w", encoding="utf8") as file:
|
231
|
+
file.write(massaged_txt)
|
232
|
+
logger.info("Overwrite txt file: %s", txt_filename.resolve())
|
233
|
+
|
234
|
+
|
235
|
+
def _new_file(args, massaged_txt) -> None:
|
236
|
+
txt_filename = Path(args.input_file.name)
|
237
|
+
export_filename = Path(
|
238
|
+
txt_filename.resolve().parent.joinpath(
|
239
|
+
args.output_folder, txt_filename.name
|
240
|
+
)
|
241
|
+
)
|
242
|
+
export_filename.parent.mkdir(parents=True, exist_ok=True)
|
216
243
|
|
217
|
-
|
218
|
-
|
244
|
+
with open(export_filename, "w", encoding="utf8") as file:
|
245
|
+
file.write(massaged_txt)
|
246
|
+
logger.info("New txt file: %s", export_filename.resolve())
|
219
247
|
|
220
248
|
|
221
249
|
def header_number(args: argparse.Namespace, book: Book) -> Book:
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: txt2ebook
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.146
|
4
4
|
Summary: CLI tool to convert txt file to ebook format
|
5
5
|
Project-URL: Homepage, https://github.com/kianmeng/txt2ebook
|
6
6
|
Project-URL: Repository, https://github.com/kianmeng/txt2ebook
|
7
7
|
Author-email: Kian-Meng Ang <kianmeng@cpan.org>
|
8
8
|
License-Expression: AGPL-3.0-or-later
|
9
9
|
License-File: LICENSE.md
|
10
|
-
Keywords: cjk,ebook,epub,txt
|
10
|
+
Keywords: cjk,ebook,epub,gmi,latex,md,pdf,txt,typst
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
12
12
|
Classifier: Environment :: Console
|
13
13
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
@@ -50,19 +50,13 @@ A console tool to convert txt file to different ebook formats.
|
|
50
50
|
Stable version From PyPI:
|
51
51
|
|
52
52
|
```console
|
53
|
-
|
53
|
+
uv tool install txt2ebook
|
54
54
|
```
|
55
55
|
|
56
56
|
Upgrade to latest stable version:
|
57
57
|
|
58
58
|
```console
|
59
|
-
|
60
|
-
```
|
61
|
-
|
62
|
-
Latest development version from GitHub:
|
63
|
-
|
64
|
-
```console
|
65
|
-
python3 -m pip install -e git+https://github.com/kianmeng/txt2ebook.git
|
59
|
+
uv tool upgrade txt2ebook
|
66
60
|
```
|
67
61
|
|
68
62
|
## Usage
|
@@ -108,12 +102,12 @@ positional arguments:
|
|
108
102
|
typ
|
109
103
|
generate ebook in Typst format
|
110
104
|
|
111
|
-
|
112
|
-
-of
|
105
|
+
options:
|
106
|
+
-of, --output-folder OUTPUT_FOLDER
|
113
107
|
set default output folder (default: 'output')
|
114
108
|
-p, --purge
|
115
109
|
remove converted ebooks specified by --output-folder option (default: 'False')
|
116
|
-
-l
|
110
|
+
-l, --language LANGUAGE
|
117
111
|
language of the ebook (default: 'None')
|
118
112
|
-rw, --raise-on-warning
|
119
113
|
raise exception and stop parsing upon warning
|
@@ -21,7 +21,7 @@ txt2ebook/formats/templates/epub/condense.css,sha256=Fz80ZqkPsFRmGdURduAxqMV8drD
|
|
21
21
|
txt2ebook/formats/templates/epub/noindent.css,sha256=_O5Tv90TKyyPBRdgjuNKFwtKFbdheh2V9PtDhgRUg3U,483
|
22
22
|
txt2ebook/helpers/__init__.py,sha256=c2EItHvPABDORfgfjArfa5XR--43es4D1tKWqaPcBxY,1309
|
23
23
|
txt2ebook/languages/__init__.py,sha256=1AfDn-D0q-dvODGP-9KxPHY_Wtk-ifZdN1FutZMT9-Q,763
|
24
|
-
txt2ebook/languages/en.py,sha256=
|
24
|
+
txt2ebook/languages/en.py,sha256=8qsmbKB69M3SD9nBnSX8rP8hAL_RFkhB-zyH93INgaQ,999
|
25
25
|
txt2ebook/languages/zh_cn.py,sha256=lcbgPFO4Uaog8sKHKF5fQtvRwkKiQ3v5wMvYNEvNk9k,1943
|
26
26
|
txt2ebook/languages/zh_tw.py,sha256=_fdXOOSLK0nTMuBe1Om2qjb4zr2PVd6N4xi2rrYkNTI,1515
|
27
27
|
txt2ebook/locales/txt2ebook.pot,sha256=mAbxkYqivFTrRmmo412Um3ZcvIS_yGiG7zxE3MCRavU,641
|
@@ -39,14 +39,14 @@ txt2ebook/subcommands/__init__.py,sha256=1O_yTOheT9QwYarGl-zqFsVtcYveL4R9EztEeSF
|
|
39
39
|
txt2ebook/subcommands/env.py,sha256=gEzra4b6guy7pRZUTCWX1_eiR7JmrtR1Z-J-vxljvMY,1549
|
40
40
|
txt2ebook/subcommands/epub.py,sha256=_obM1_fvVBPHOBXBOCYK8nyJadBX3_gOn9kaXA5HipA,3570
|
41
41
|
txt2ebook/subcommands/gmi.py,sha256=TUHoQ05q3TofYDRBAcXaDtqFWbqV0VcJHzFfGYKbqYs,3304
|
42
|
-
txt2ebook/subcommands/massage.py,sha256=
|
42
|
+
txt2ebook/subcommands/massage.py,sha256=PL0dVaJiGDRrhN7xCY1jvRkveS3zM0PoiPcbZuUIrMQ,12767
|
43
43
|
txt2ebook/subcommands/md.py,sha256=hwb65z95NTSLAz87FJI7ZLB3du1pBx3A4FlF2UD2xio,3315
|
44
44
|
txt2ebook/subcommands/parse.py,sha256=tdWqssFsg70GSgz4S2YoaERydt3zQ5Sq1rLtkvB-WQU,2902
|
45
45
|
txt2ebook/subcommands/pdf.py,sha256=-DjeMmRKPZoTg8WZfNc028ZaZZ3xLCSAdnZDZFtCsbI,2966
|
46
46
|
txt2ebook/subcommands/tex.py,sha256=4Wk_-l3UzuJYck0oWkRaKXVrf05jkGTJiyc7YORwMK0,3117
|
47
47
|
txt2ebook/subcommands/typ.py,sha256=qCbaGFP5n6yJ-P6biXw2JHhjiYk3emOpthoSf9XWhOY,3667
|
48
|
-
txt2ebook-0.1.
|
49
|
-
txt2ebook-0.1.
|
50
|
-
txt2ebook-0.1.
|
51
|
-
txt2ebook-0.1.
|
52
|
-
txt2ebook-0.1.
|
48
|
+
txt2ebook-0.1.146.dist-info/METADATA,sha256=E5zhsWM_PYGHlUDb3f-_wRrzazLNahwidU2HGPcy3tw,4737
|
49
|
+
txt2ebook-0.1.146.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
50
|
+
txt2ebook-0.1.146.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
|
51
|
+
txt2ebook-0.1.146.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
|
52
|
+
txt2ebook-0.1.146.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|