txt2ebook 0.1.156__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txt2ebook
3
- Version: 0.1.156
3
+ Version: 0.1.157
4
4
  Summary: CLI tool to convert txt file to ebook format
5
5
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -39,6 +39,22 @@ Requires-Dist: regex<2022,>=2021.11.10
39
39
  Requires-Dist: reportlab<5,>=4.0.0
40
40
  Requires-Dist: typing-extensions<5,>=4.5.0
41
41
  Requires-Dist: typst>=0.13.0
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"
42
58
  Dynamic: license-file
43
59
 
44
60
  # txt2ebook
@@ -29,15 +29,15 @@ txt2ebook/subcommands/__init__.py,sha256=ldhzvsrMsR8lZmhZef77JFz0jValpV3pytFfwJS
29
29
  txt2ebook/subcommands/env.py,sha256=gEzra4b6guy7pRZUTCWX1_eiR7JmrtR1Z-J-vxljvMY,1549
30
30
  txt2ebook/subcommands/epub.py,sha256=oVk00rypqN53UAOIYhOofkAPbjrdlvkszLDIdVqexvE,4706
31
31
  txt2ebook/subcommands/gmi.py,sha256=ANnPg-RFsylTo44fUzFOSHN1fC3Ce82gBzrv-sBv5fU,3318
32
- txt2ebook/subcommands/massage.py,sha256=cjeee4wJJ6xPV76efnlWRVdeVkEtJYIBDaKhFMPjKTg,14643
32
+ txt2ebook/subcommands/massage.py,sha256=WmHHJQLowdjSDQnEqxVKsU9YsabY7fw4mBkfddsFZpI,15535
33
33
  txt2ebook/subcommands/md.py,sha256=PmIqrqrnzLywvN4qTkle0V9N3FTIJGRWpC0Xbk76B5o,3329
34
34
  txt2ebook/subcommands/parse.py,sha256=xjhW8I9zS5DL3n3m04RyFofgci-6-_L6aF3d4N7c7M4,2938
35
35
  txt2ebook/subcommands/pdf.py,sha256=1JQtpugzAIaho6G3CK1rGYk74hotAexXZxPH9PHpRps,2980
36
36
  txt2ebook/subcommands/tex.py,sha256=8XqTV5GsOEr7sGSLUJB-B1KefIMxW3_BDq_Jm96Bt1Y,4369
37
37
  txt2ebook/subcommands/typ.py,sha256=xeJ_cPmyq_uouUBiH2kbcscckHLqewPmu9j0WO36sXY,4814
38
- txt2ebook-0.1.156.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
39
- txt2ebook-0.1.156.dist-info/METADATA,sha256=FmlT-uz7lE9ZU6vp0U3X96lRMQSeNHEcuAu6NdQn7dw,4664
40
- txt2ebook-0.1.156.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- txt2ebook-0.1.156.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
42
- txt2ebook-0.1.156.dist-info/top_level.txt,sha256=pesdk4CJRlfhUXVD9vH3Dd_F8ATlLQoqlUsUnU8SJMw,10
43
- txt2ebook-0.1.156.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,,