txt2ebook 0.1.110__py3-none-any.whl → 0.1.112__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/__init__.py CHANGED
@@ -22,7 +22,7 @@ import sys
22
22
 
23
23
  logger = logging.getLogger(__name__)
24
24
 
25
- __version__ = "0.1.110"
25
+ __version__ = "0.1.112"
26
26
 
27
27
 
28
28
  def setup_logger(config: argparse.Namespace) -> None:
txt2ebook/cli.py CHANGED
@@ -26,7 +26,9 @@ import sys
26
26
  from typing import Optional, Sequence
27
27
 
28
28
  import txt2ebook.subcommands.env
29
+ import txt2ebook.subcommands.epub
29
30
  import txt2ebook.subcommands.massage
31
+ import txt2ebook.subcommands.md
30
32
  import txt2ebook.subcommands.parse
31
33
  import txt2ebook.subcommands.tex
32
34
  from txt2ebook import __version__, setup_logger
@@ -283,7 +285,9 @@ def build_parser(
283
285
  subparsers = parser.add_subparsers(help="sub-command help")
284
286
  txt2ebook.subcommands.parse.build_subparser(subparsers)
285
287
  txt2ebook.subcommands.massage.build_subparser(subparsers)
288
+ txt2ebook.subcommands.epub.build_subparser(subparsers)
286
289
  txt2ebook.subcommands.tex.build_subparser(subparsers)
290
+ txt2ebook.subcommands.md.build_subparser(subparsers)
287
291
  txt2ebook.subcommands.env.build_subparser(subparsers)
288
292
 
289
293
  return parser
@@ -0,0 +1,94 @@
1
+ # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Affero General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Affero General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Affero General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ """Epub subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+ import sys
21
+
22
+ from txt2ebook.subcommands.parse import run as parse_txt
23
+ from txt2ebook.formats.epub import EpubWriter
24
+ from txt2ebook.formats import EPUB_TEMPLATES
25
+
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+
30
+ def build_subparser(subparsers) -> None:
31
+ """Build the subparser."""
32
+ epub_parser = subparsers.add_parser(
33
+ "epub", help="generate ebook in EPUB format"
34
+ )
35
+
36
+ epub_parser.set_defaults(func=run)
37
+
38
+ epub_parser.add_argument(
39
+ "input_file",
40
+ nargs=None if sys.stdin.isatty() else "?", # type: ignore
41
+ type=argparse.FileType("rb"),
42
+ default=None if sys.stdin.isatty() else sys.stdin,
43
+ help="source text filename",
44
+ metavar="TXT_FILENAME",
45
+ )
46
+
47
+ epub_parser.add_argument(
48
+ "output_file",
49
+ nargs="?",
50
+ default=None,
51
+ help="converted ebook filename (default: 'TXT_FILENAME.epub')",
52
+ metavar="EBOOK_FILENAME",
53
+ )
54
+
55
+ epub_parser.add_argument(
56
+ "-c",
57
+ "--cover",
58
+ dest="cover",
59
+ default=None,
60
+ help="cover of the ebook",
61
+ metavar="IMAGE_FILENAME",
62
+ )
63
+
64
+ epub_parser.add_argument(
65
+ "-et",
66
+ "--epub-template",
67
+ default="clean",
68
+ choices=EPUB_TEMPLATES,
69
+ dest="epub_template",
70
+ help="CSS template for epub ebook (default: '%(default)s')",
71
+ )
72
+
73
+ epub_parser.add_argument(
74
+ "-vp",
75
+ "--volume-page",
76
+ default=False,
77
+ action="store_true",
78
+ dest="volume_page",
79
+ help="generate each volume as separate page",
80
+ )
81
+
82
+
83
+ def run(args: argparse.Namespace) -> None:
84
+ """Run epub subcommand.
85
+
86
+ Args:
87
+ config (argparse.Namespace): Config from command line arguments
88
+
89
+ Returns:
90
+ None
91
+ """
92
+ book = parse_txt(args)
93
+ writer = EpubWriter(book, args)
94
+ writer.write()
@@ -0,0 +1,87 @@
1
+ # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Affero General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Affero General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Affero General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ """md subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+ import sys
21
+
22
+ from txt2ebook.subcommands.parse import run as parse_txt
23
+ from txt2ebook.formats.md import MdWriter as MarkdownWriter
24
+
25
+
26
+ logger = logging.getLogger(__name__)
27
+
28
+
29
+ def build_subparser(subparsers) -> None:
30
+ """Build the subparser."""
31
+ md_parser = subparsers.add_parser(
32
+ "md", help="generate ebook in Markdown format"
33
+ )
34
+
35
+ md_parser.set_defaults(func=run)
36
+
37
+ md_parser.add_argument(
38
+ "input_file",
39
+ nargs=None if sys.stdin.isatty() else "?", # type: ignore
40
+ type=argparse.FileType("rb"),
41
+ default=None if sys.stdin.isatty() else sys.stdin,
42
+ help="source text filename",
43
+ metavar="TXT_FILENAME",
44
+ )
45
+
46
+ md_parser.add_argument(
47
+ "output_file",
48
+ nargs="?",
49
+ default=None,
50
+ help="converted ebook filename (default: 'TXT_FILENAME.md')",
51
+ metavar="EBOOK_FILENAME",
52
+ )
53
+
54
+ md_parser.add_argument(
55
+ "-sp",
56
+ "--split-volume-and-chapter",
57
+ default=False,
58
+ action="store_true",
59
+ dest="split_volume_and_chapter",
60
+ help=(
61
+ "split volume or chapter into separate file and "
62
+ "ignore the --overwrite option"
63
+ ),
64
+ )
65
+
66
+ md_parser.add_argument(
67
+ "-toc",
68
+ "--table-of-content",
69
+ default=False,
70
+ action="store_true",
71
+ dest="with_toc",
72
+ help="add table of content",
73
+ )
74
+
75
+
76
+ def run(args: argparse.Namespace) -> None:
77
+ """Run md subcommand.
78
+
79
+ Args:
80
+ config (argparse.Namespace): Config from command line arguments
81
+
82
+ Returns:
83
+ None
84
+ """
85
+ book = parse_txt(args)
86
+ writer = MarkdownWriter(book, args)
87
+ writer.write()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txt2ebook
3
- Version: 0.1.110
3
+ Version: 0.1.112
4
4
  Summary: CLI tool to convert txt file to ebook format
5
5
  Home-page: https://github.com/kianmeng/txt2ebook
6
6
  License: AGPL-3.0-or-later
@@ -1,6 +1,6 @@
1
- txt2ebook/__init__.py,sha256=QRgjJXRHQ_w5EDI7mVUFTGQSlGvWZa5XBip_k0sj4X0,2062
1
+ txt2ebook/__init__.py,sha256=aPLmaeNFAoTluwaX47RB9YvnRDaSSl-fPG4ezGS2ckY,2062
2
2
  txt2ebook/__main__.py,sha256=gMLvgpqc_BL4cBqNe0vqErRF5dlJPAbvqu1zndcAHYI,850
3
- txt2ebook/cli.py,sha256=ehog7m-ePN-KlkIizCNHIgEApn8VUvcW0UMSaKa3Gfo,8180
3
+ txt2ebook/cli.py,sha256=LLwnhIqirbpyQVfeHbmJYysSU9NRMHusFVe5bYQ2_Ws,8362
4
4
  txt2ebook/exceptions.py,sha256=b2HDsXdqweLJbvSJEGt48nxvGkZq20SfYezSjwp77JU,842
5
5
  txt2ebook/formats/__init__.py,sha256=WhiRWGvbUjc8QZfhAIkKCg6GL8vNNlEF73meZSzYhDA,2463
6
6
  txt2ebook/formats/base.py,sha256=SMt6Op88-HoIxRA-tgPBNSlrt7-KZ-m5-BytAEJT4m0,5814
@@ -34,14 +34,16 @@ txt2ebook/models/chapter.py,sha256=buECAklNQgM3tDehzyVO9YfA_F0iXyLq2PaMZGV_Zaw,1
34
34
  txt2ebook/models/volume.py,sha256=HyT4XO9yZ8d0PgZVfMMyAYUDFv58RrUmsSFNNmU-sHY,1592
35
35
  txt2ebook/parser.py,sha256=2Dk1n51Czb3Tn_a1tgSSx5A-XNETVyuX4gJ9nQ-fPlQ,8707
36
36
  txt2ebook/subcommands/env.py,sha256=26wcAhEbjKfWYeNiIsjm9TTaBUyNDYx1MYUtV2ZFkmg,1481
37
+ txt2ebook/subcommands/epub.py,sha256=evZgvi1cHe3uCHgAwteJ2FlXFk3YOUekYNghVk7ySgE,2578
37
38
  txt2ebook/subcommands/massage.py,sha256=on4Oqpv3WwOf6tZVGFzwq972oGa6TaJx7Is_0YSnmBI,5766
39
+ txt2ebook/subcommands/md.py,sha256=v-xSWEpe6p9hIDRh-Nk1uH43P9gOvy80g-qt11dG-aw,2418
38
40
  txt2ebook/subcommands/parse.py,sha256=1QEVRzgDZYiwOs-36WYPNFIIc-GgKCp8eBxZKuzqQa8,2607
39
41
  txt2ebook/subcommands/tex.py,sha256=O2Sl-v8tTU_bMFDDukFYEyXBTecGzp3Ll8Gqom63Clk,2330
40
42
  txt2ebook/tokenizer.py,sha256=HJEub1NYTaH3FMfzzdaNpmimzgzGN942m9O7oDHqkuQ,9456
41
43
  txt2ebook/txt2ebook.py,sha256=GwWjSk2HbnGrOM59qFsPv2CMqAgv1GBxy_r1zkgBEvQ,13969
42
44
  txt2ebook/zh_utils.py,sha256=EgKVbwqYGaTGswQUGcOCeSfRelzwkAb9WWY9TrsX1x4,4882
43
- txt2ebook-0.1.110.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
44
- txt2ebook-0.1.110.dist-info/METADATA,sha256=SKdHnmQdouLQajIuY3e2P7QLrh56zsfwRYy171A6jPw,7754
45
- txt2ebook-0.1.110.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
46
- txt2ebook-0.1.110.dist-info/entry_points.txt,sha256=JLW3Iv7eUyABlQeUFiUWQhLKfRdnB9o5SIcNlneGR0Q,77
47
- txt2ebook-0.1.110.dist-info/RECORD,,
45
+ txt2ebook-0.1.112.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
46
+ txt2ebook-0.1.112.dist-info/METADATA,sha256=amyhdLNk3kzqJy5wis5MAoOYUo4u1CxvHtoauC2-J60,7754
47
+ txt2ebook-0.1.112.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
48
+ txt2ebook-0.1.112.dist-info/entry_points.txt,sha256=JLW3Iv7eUyABlQeUFiUWQhLKfRdnB9o5SIcNlneGR0Q,77
49
+ txt2ebook-0.1.112.dist-info/RECORD,,