txt2ebook 0.1.155__py3-none-any.whl → 0.1.157__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.
@@ -210,7 +210,7 @@ def run(args: argparse.Namespace) -> None:
210
210
  """Run massage subcommand.
211
211
 
212
212
  Args:
213
- args (argparse.Namespace): args.from command line arguments
213
+ args (argparse.Namespace): arguments from command line arguments
214
214
 
215
215
  Returns:
216
216
  None
@@ -472,7 +472,6 @@ def extract_metadata_and_body(_args, content: str) -> tuple:
472
472
  metadata = match.group(0).strip()
473
473
  body = content.replace(metadata, "", 1)
474
474
 
475
-
476
475
  metadata_block = metadata.split("---")[1]
477
476
 
478
477
  metadata_dict = {}
@@ -492,33 +491,38 @@ def extract_metadata_and_body(_args, content: str) -> tuple:
492
491
  return (meta_str, body)
493
492
 
494
493
 
495
- def do_single_newline(args, content: str) -> str:
494
+ def do_single_newline(args: argparse.Namespace, content: str) -> str:
496
495
  """Set single newline.
497
496
 
498
497
  Args:
499
- content (str): The formatted book content.
498
+ args (argparse.Namespace): arguments from command line arguments
499
+ content (str): The formatted book content
500
500
 
501
501
  Returns:
502
502
  str: The formatted book content.
503
503
  """
504
- modified_content = re.sub(r"\n+", "\n\n", content)
504
+ unwrap_content = _unwrap_content(args, content)
505
+ modified_content = re.sub(r"\n+", "\n\n", unwrap_content)
505
506
  return modified_content
506
507
 
507
508
 
508
- def do_wrapping(args, content: str) -> str:
509
+ def do_wrapping(args: argparse.Namespace, content: str) -> str:
509
510
  """Wrap or fill CJK text.
510
511
 
511
512
  Args:
512
- content (str): The formatted book content.
513
+ args (argparse.Namespace): arguments from command line arguments
514
+ content (str): The formatted book content
513
515
 
514
516
  Returns:
515
517
  str: The formatted book content.
516
518
  """
517
519
  logger.info("Wrapping paragraph to width: %s", args.width)
518
520
 
521
+ unwrap_content = _unwrap_content(args, content)
522
+
523
+ # don't remove empty line and keep all formatting as it
519
524
  paragraphs = []
520
- # We don't remove empty line and keep all formatting as it.
521
- for paragraph in content.split("\n"):
525
+ for paragraph in unwrap_content.split("\n"):
522
526
  paragraph = paragraph.strip()
523
527
 
524
528
  lines = cjkwrap.wrap(paragraph, width=args.width)
@@ -527,3 +531,20 @@ def do_wrapping(args, content: str) -> str:
527
531
 
528
532
  wrapped_content = "\n".join(paragraphs)
529
533
  return wrapped_content
534
+
535
+
536
+ def _unwrap_content(args: argparse.Namespace, content: str) -> str:
537
+ """
538
+ Args:
539
+ args (argparse.Namespace): arguments from command line arguments
540
+ content (str): The formatted book content
541
+
542
+ Returns:
543
+ str: The formatted book content.
544
+ """
545
+ paragraphs = content.split(args.paragraph_separator)
546
+ processed_paragraphs = []
547
+ for paragraph in paragraphs:
548
+ single_line_paragraph = " ".join(paragraph.splitlines())
549
+ processed_paragraphs.append(single_line_paragraph.strip())
550
+ return args.paragraph_separator.join(processed_paragraphs)
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txt2ebook
3
- Version: 0.1.155
3
+ Version: 0.1.157
4
4
  Summary: CLI tool to convert txt file to ebook format
5
- Keywords: cjk,ebook,epub,gmi,latex,md,pdf,txt,typst
6
5
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
7
- Requires-Python: ~=3.9
8
- Description-Content-Type: text/markdown
6
+ License-Expression: AGPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/kianmeng/txt2ebook
8
+ Project-URL: Repository, https://github.com/kianmeng/txt2ebook
9
+ Keywords: cjk,ebook,epub,gmi,latex,md,pdf,txt,typst
9
10
  Classifier: Development Status :: 4 - Beta
10
11
  Classifier: Environment :: Console
11
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
12
12
  Classifier: Natural Language :: Chinese (Simplified)
13
13
  Classifier: Natural Language :: Chinese (Traditional)
14
14
  Classifier: Programming Language :: Python
@@ -23,22 +23,39 @@ Classifier: Topic :: Text Processing :: Filters
23
23
  Classifier: Topic :: Text Processing :: General
24
24
  Classifier: Topic :: Text Processing :: Markup :: HTML
25
25
  Classifier: Topic :: Text Processing :: Markup :: Markdown
26
+ Requires-Python: ~=3.9
27
+ Description-Content-Type: text/markdown
26
28
  License-File: LICENSE.md
27
29
  Requires-Dist: CJKwrap~=2.2
28
- Requires-Dist: EbookLib>=0.17.1,<0.18
29
- Requires-Dist: bs4>=0.0.1,<0.0.2
30
- Requires-Dist: importlib-resources>=6.1.1,<7
31
- Requires-Dist: jieba>=0.42.1,<0.43
32
- Requires-Dist: langdetect>=1.0.9,<2
33
- Requires-Dist: lxml>=5.2.2,<6
34
- Requires-Dist: pylatex>=1.4.2,<2
30
+ Requires-Dist: EbookLib<0.18,>=0.17.1
31
+ Requires-Dist: bs4<0.0.2,>=0.0.1
32
+ Requires-Dist: importlib-resources<7,>=6.1.1
33
+ Requires-Dist: jieba<0.43,>=0.42.1
34
+ Requires-Dist: langdetect<2,>=1.0.9
35
+ Requires-Dist: lxml<6,>=5.2.2
36
+ Requires-Dist: pylatex<2,>=1.4.2
35
37
  Requires-Dist: pypandoc~=1.11
36
- Requires-Dist: regex>=2021.11.10,<2022
37
- Requires-Dist: reportlab>=4.0.0,<5
38
- Requires-Dist: typing-extensions>=4.5.0,<5
38
+ Requires-Dist: regex<2022,>=2021.11.10
39
+ Requires-Dist: reportlab<5,>=4.0.0
40
+ Requires-Dist: typing-extensions<5,>=4.5.0
39
41
  Requires-Dist: typst>=0.13.0
40
- Project-URL: Homepage, https://github.com/kianmeng/txt2ebook
41
- Project-URL: Repository, https://github.com/kianmeng/txt2ebook
42
+ Provides-Extra: test
43
+ Requires-Dist: pytest; extra == "test"
44
+ Requires-Dist: pytest-cov; extra == "test"
45
+ Requires-Dist: pytest-randomly; extra == "test"
46
+ Requires-Dist: pytest-xdist; extra == "test"
47
+ Requires-Dist: scripttest; extra == "test"
48
+ Provides-Extra: doc
49
+ Requires-Dist: myst-parser; extra == "doc"
50
+ Requires-Dist: sphinx; extra == "doc"
51
+ Requires-Dist: sphinx-autobuild; extra == "doc"
52
+ Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
53
+ Requires-Dist: sphinx-copybutton; extra == "doc"
54
+ Provides-Extra: lint
55
+ Requires-Dist: pre-commit; extra == "lint"
56
+ Requires-Dist: ruff; extra == "lint"
57
+ Requires-Dist: mypy; extra == "lint"
58
+ Dynamic: license-file
42
59
 
43
60
  # txt2ebook
44
61
 
@@ -150,4 +167,3 @@ The fish logo used in the documentation generated by Sphinx is a public domain
150
167
  drawing of Troschel's parrotfish (Chlorurus troschelii Var. A.) from
151
168
  <https://commons.wikimedia.org/entity/M18506436>.
152
169
  18506436>.
153
-
@@ -16,21 +16,11 @@ txt2ebook/formats/txt.py,sha256=0DOVBTDRV2gcixham5Wj7NaZlNKAeLG9MLRlZgtUxqM,7412
16
16
  txt2ebook/formats/typ.py,sha256=MNclD5RdCnYAmPRzAaI6ZE6NnI8GdHKJla54wyfTUdc,6705
17
17
  txt2ebook/formats/templates/__init__.py,sha256=f3K7pJByNmmvu-wvziks6qb2QnnLmkDjUACXyw2s60E,760
18
18
  txt2ebook/formats/templates/epub/__init__.py,sha256=-XVLvnknTJTmQZY9UTH705vMcHgy56rQVRTusYawEZ4,766
19
- txt2ebook/formats/templates/epub/clean.css,sha256=AnEwMckzUSKcjKsDiWtJW1oaceuklt2tyuS1VbpVK1s,462
20
- txt2ebook/formats/templates/epub/condense.css,sha256=Fz80ZqkPsFRmGdURduAxqMV8drD0CCUlrv41P8rUsm8,477
21
- txt2ebook/formats/templates/epub/noindent.css,sha256=_O5Tv90TKyyPBRdgjuNKFwtKFbdheh2V9PtDhgRUg3U,483
22
19
  txt2ebook/helpers/__init__.py,sha256=c2EItHvPABDORfgfjArfa5XR--43es4D1tKWqaPcBxY,1309
23
20
  txt2ebook/languages/__init__.py,sha256=1AfDn-D0q-dvODGP-9KxPHY_Wtk-ifZdN1FutZMT9-Q,763
24
21
  txt2ebook/languages/en.py,sha256=8qsmbKB69M3SD9nBnSX8rP8hAL_RFkhB-zyH93INgaQ,999
25
22
  txt2ebook/languages/zh_cn.py,sha256=ryKMeaNgX2J6BGrHl7KZL9S6HwIlTyLk75z3lvVQIi4,1960
26
23
  txt2ebook/languages/zh_tw.py,sha256=_fdXOOSLK0nTMuBe1Om2qjb4zr2PVd6N4xi2rrYkNTI,1515
27
- txt2ebook/locales/txt2ebook.pot,sha256=VoXU9LrDzZApUVCCcKZC5Fu5QLx1fwd1lYEkbIdCEgc,641
28
- txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo,sha256=Ym6soeijV3zsv9FUPWlJnu18-CNb5tcOTN5JsMOfV9c,672
29
- txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po,sha256=ENsZFITaqEdOYE3xkPX5wDR1HMs1JqB7uyrHaAdPiE0,698
30
- txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo,sha256=rRGW7HByDVZV8WpQkhyIFOWYNTQc4NnStrn0eGJX8Wc,675
31
- txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po,sha256=i_B-urg-eik0myXxIBSV8_ohPu3xsPNWHJP-fcATotg,698
32
- txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo,sha256=1GIuOcO_bISiFcfhFez-A7mSi11Mo-x3PBobBENgMEc,675
33
- txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po,sha256=sNyEKCHin78wmSwUARfAypsl9mXfJJaWD1a8E1ixKjs,698
34
24
  txt2ebook/models/__init__.py,sha256=Z3zClWLj08Q8HgaWV1RRgIKatEhIUfYBAVWm-j4m05w,930
35
25
  txt2ebook/models/book.py,sha256=P-SQabvrRgWoafrk0tw6zjD-3hq_r8_jGvgTORUS-DM,2730
36
26
  txt2ebook/models/chapter.py,sha256=6YvUDHzR6amGMZgkQl_xHWrYZUmlfpF7mnDLilG2BpA,1686
@@ -39,14 +29,15 @@ txt2ebook/subcommands/__init__.py,sha256=ldhzvsrMsR8lZmhZef77JFz0jValpV3pytFfwJS
39
29
  txt2ebook/subcommands/env.py,sha256=gEzra4b6guy7pRZUTCWX1_eiR7JmrtR1Z-J-vxljvMY,1549
40
30
  txt2ebook/subcommands/epub.py,sha256=oVk00rypqN53UAOIYhOofkAPbjrdlvkszLDIdVqexvE,4706
41
31
  txt2ebook/subcommands/gmi.py,sha256=ANnPg-RFsylTo44fUzFOSHN1fC3Ce82gBzrv-sBv5fU,3318
42
- txt2ebook/subcommands/massage.py,sha256=cjeee4wJJ6xPV76efnlWRVdeVkEtJYIBDaKhFMPjKTg,14643
32
+ txt2ebook/subcommands/massage.py,sha256=WmHHJQLowdjSDQnEqxVKsU9YsabY7fw4mBkfddsFZpI,15535
43
33
  txt2ebook/subcommands/md.py,sha256=PmIqrqrnzLywvN4qTkle0V9N3FTIJGRWpC0Xbk76B5o,3329
44
34
  txt2ebook/subcommands/parse.py,sha256=xjhW8I9zS5DL3n3m04RyFofgci-6-_L6aF3d4N7c7M4,2938
45
35
  txt2ebook/subcommands/pdf.py,sha256=1JQtpugzAIaho6G3CK1rGYk74hotAexXZxPH9PHpRps,2980
46
36
  txt2ebook/subcommands/tex.py,sha256=8XqTV5GsOEr7sGSLUJB-B1KefIMxW3_BDq_Jm96Bt1Y,4369
47
37
  txt2ebook/subcommands/typ.py,sha256=xeJ_cPmyq_uouUBiH2kbcscckHLqewPmu9j0WO36sXY,4814
48
- txt2ebook-0.1.155.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
49
- txt2ebook-0.1.155.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
50
- txt2ebook-0.1.155.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
51
- txt2ebook-0.1.155.dist-info/METADATA,sha256=m8QqLQ3zSn6ySbwjopHdbc0kswDZzb6JZUXGSzRVvz8,4700
52
- txt2ebook-0.1.155.dist-info/RECORD,,
38
+ txt2ebook-0.1.157.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
39
+ txt2ebook-0.1.157.dist-info/METADATA,sha256=WSRHi5sIRSNXPlUpUSYK7GWueOhHAdczDQfC3XSUHX4,5295
40
+ txt2ebook-0.1.157.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ txt2ebook-0.1.157.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
42
+ txt2ebook-0.1.157.dist-info/top_level.txt,sha256=pesdk4CJRlfhUXVD9vH3Dd_F8ATlLQoqlUsUnU8SJMw,10
43
+ txt2ebook-0.1.157.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.12.0
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ tte = txt2ebook.cli:main
3
+ txt2ebook = txt2ebook.cli:main
@@ -0,0 +1 @@
1
+ txt2ebook
@@ -1,41 +0,0 @@
1
- /* cover page */
2
- div#cover {
3
- text-align: center;
4
- width: 100%;
5
- }
6
-
7
- /* navigation page - toc */
8
- ol {
9
- list-style-type: none;
10
- padding-left: 0;
11
- }
12
-
13
- ol li {
14
- padding-top: 0.2em;
15
- }
16
-
17
- ol li ol li:last-of-type {
18
- padding-bottom: 1em;
19
- }
20
-
21
- ol li a {
22
- text-decoration: none;
23
- }
24
-
25
- /* chapters & section */
26
- div.volume {
27
- display: table;
28
- width: 100%;
29
- height: 100%;
30
- }
31
-
32
- h1.volume {
33
- display: table-cell;
34
- text-align: center;
35
- vertical-align: middle;
36
- }
37
-
38
- h2 {
39
- }
40
- p {
41
- }
@@ -1,42 +0,0 @@
1
- /* cover page */
2
- div#cover {
3
- text-align: center;
4
- width: 100%;
5
- }
6
-
7
- /* navigation page - toc */
8
- ol {
9
- list-style-type: none;
10
- padding-left: 0;
11
- }
12
-
13
- ol li {
14
- padding-top: 0.2em;
15
- }
16
-
17
- ol li ol li:last-of-type {
18
- padding-bottom: 1em;
19
- }
20
-
21
- ol li a {
22
- text-decoration: none;
23
- }
24
-
25
- /* chapters & section */
26
- div.volume {
27
- display: table;
28
- width: 100%;
29
- height: 100%;
30
- }
31
-
32
- h1.volume {
33
- display: table-cell;
34
- text-align: center;
35
- vertical-align: middle;
36
- }
37
-
38
- h2 {
39
- }
40
- p {
41
- margin: 0em;
42
- }
@@ -1,42 +0,0 @@
1
- /* cover page */
2
- div#cover {
3
- text-align: center;
4
- width: 100%;
5
- }
6
-
7
- /* navigation page - toc */
8
- ol {
9
- list-style-type: none;
10
- padding-left: 0;
11
- }
12
-
13
- ol li {
14
- padding-top: 0.2em;
15
- }
16
-
17
- ol li ol li:last-of-type {
18
- padding-bottom: 1em;
19
- }
20
-
21
- ol li a {
22
- text-decoration: none;
23
- }
24
-
25
- /* chapters & section */
26
- div.volume {
27
- display: table;
28
- width: 100%;
29
- height: 100%;
30
- }
31
-
32
- h1.volume {
33
- display: table-cell;
34
- text-align: center;
35
- vertical-align: middle;
36
- }
37
-
38
- h2 {
39
- }
40
- p {
41
- text-indent: -2em;
42
- }
@@ -1,31 +0,0 @@
1
- #: src/txt2ebook/formats/base.py:139
2
- msgid "title:"
3
- msgstr "Title:"
4
-
5
- #: src/txt2ebook/formats/base.py:140
6
- msgid "author:"
7
- msgstr "Author:"
8
-
9
- #: src/txt2ebook/formats/base.py:141
10
- msgid "translator:"
11
- msgstr "Translator:"
12
-
13
- #: src/txt2ebook/formats/base.py:142
14
- msgid "tag:"
15
- msgstr "Tag:"
16
-
17
- #: src/txt2ebook/formats/base.py:153 src/txt2ebook/formats/gmi.py:62
18
- #: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
19
- #: src/txt2ebook/formats/txt.py:71
20
- msgid "toc"
21
- msgstr "Table of Content"
22
-
23
- #: src/txt2ebook/formats/epub.py:147
24
- msgid "cover"
25
- msgstr "Cover"
26
-
27
- #: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
28
- #: src/txt2ebook/formats/txt.py:56
29
- msgid "metadata"
30
- msgstr "Metadata"
31
-
@@ -1,31 +0,0 @@
1
- #: src/txt2ebook/formats/base.py:139
2
- msgid "title:"
3
- msgstr ""
4
-
5
- #: src/txt2ebook/formats/base.py:140
6
- msgid "author:"
7
- msgstr ""
8
-
9
- #: src/txt2ebook/formats/base.py:141
10
- msgid "translator:"
11
- msgstr ""
12
-
13
- #: src/txt2ebook/formats/base.py:142
14
- msgid "tag:"
15
- msgstr ""
16
-
17
- #: src/txt2ebook/formats/base.py:153 src/txt2ebook/formats/gmi.py:62
18
- #: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
19
- #: src/txt2ebook/formats/txt.py:71
20
- msgid "toc"
21
- msgstr ""
22
-
23
- #: src/txt2ebook/formats/epub.py:147
24
- msgid "cover"
25
- msgstr ""
26
-
27
- #: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
28
- #: src/txt2ebook/formats/txt.py:56
29
- msgid "metadata"
30
- msgstr ""
31
-
@@ -1,31 +0,0 @@
1
- #: src/txt2ebook/formats/base.py:139
2
- msgid "title:"
3
- msgstr "书名:"
4
-
5
- #: src/txt2ebook/formats/base.py:140
6
- msgid "author:"
7
- msgstr "作者:"
8
-
9
- #: src/txt2ebook/formats/base.py:141
10
- msgid "translator:"
11
- msgstr "翻译:"
12
-
13
- #: src/txt2ebook/formats/base.py:142
14
- msgid "tag:"
15
- msgstr "票签:"
16
-
17
- #: src/txt2ebook/formats/base.py:153 src/txt2ebook/formats/gmi.py:62
18
- #: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
19
- #: src/txt2ebook/formats/txt.py:71
20
- msgid "toc"
21
- msgstr "目录"
22
-
23
- #: src/txt2ebook/formats/epub.py:147
24
- msgid "cover"
25
- msgstr "封面"
26
-
27
- #: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
28
- #: src/txt2ebook/formats/txt.py:56
29
- msgid "metadata"
30
- msgstr "元数据"
31
-
@@ -1,31 +0,0 @@
1
- #: src/txt2ebook/formats/base.py:139
2
- msgid "title:"
3
- msgstr "书名:"
4
-
5
- #: src/txt2ebook/formats/base.py:140
6
- msgid "author:"
7
- msgstr "作者:"
8
-
9
- #: src/txt2ebook/formats/base.py:141
10
- msgid "translator:"
11
- msgstr "翻译:"
12
-
13
- #: src/txt2ebook/formats/base.py:142
14
- msgid "tag:"
15
- msgstr "标签:"
16
-
17
- #: src/txt2ebook/formats/base.py:153 src/txt2ebook/formats/gmi.py:62
18
- #: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
19
- #: src/txt2ebook/formats/txt.py:71
20
- msgid "toc"
21
- msgstr "目录"
22
-
23
- #: src/txt2ebook/formats/epub.py:147
24
- msgid "cover"
25
- msgstr "封面"
26
-
27
- #: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
28
- #: src/txt2ebook/formats/txt.py:56
29
- msgid "metadata"
30
- msgstr "元数据"
31
-
@@ -1,4 +0,0 @@
1
- [console_scripts]
2
- tte=txt2ebook.cli:main
3
- txt2ebook=txt2ebook.cli:main
4
-