txt2ebook 0.1.119__tar.gz → 0.1.123__tar.gz

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.
Files changed (53) hide show
  1. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/PKG-INFO +30 -95
  2. txt2ebook-0.1.123/README.md +116 -0
  3. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/pyproject.toml +2 -2
  4. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/__init__.py +2 -2
  5. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/__main__.py +1 -1
  6. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/cli.py +2 -59
  7. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/exceptions.py +1 -1
  8. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/__init__.py +1 -1
  9. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/base.py +1 -1
  10. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/epub.py +1 -1
  11. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/gmi.py +1 -1
  12. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/md.py +1 -1
  13. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/pdf.py +1 -1
  14. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/templates/__init__.py +1 -1
  15. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/templates/epub/__init__.py +1 -1
  16. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/tex.py +1 -1
  17. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/txt.py +1 -1
  18. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/typ.py +1 -1
  19. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/helpers/__init__.py +1 -1
  20. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/languages/__init__.py +1 -1
  21. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/languages/en.py +1 -1
  22. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/languages/zh_cn.py +1 -1
  23. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/languages/zh_tw.py +1 -1
  24. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/models/__init__.py +1 -1
  25. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/models/book.py +1 -1
  26. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/models/chapter.py +1 -1
  27. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/models/volume.py +1 -1
  28. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/parser.py +7 -7
  29. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/__init__.py +1 -1
  30. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/env.py +1 -1
  31. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/epub.py +11 -1
  32. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/gmi.py +11 -1
  33. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/massage.py +1 -1
  34. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/md.py +11 -1
  35. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/parse.py +11 -1
  36. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/pdf.py +1 -1
  37. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/tex.py +1 -1
  38. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/subcommands/typ.py +11 -1
  39. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/tokenizer.py +1 -1
  40. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/zh_utils.py +1 -1
  41. txt2ebook-0.1.119/README.md +0 -181
  42. txt2ebook-0.1.119/src/txt2ebook/txt2ebook.py +0 -533
  43. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/LICENSE.md +0 -0
  44. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/templates/epub/clean.css +0 -0
  45. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/templates/epub/condense.css +0 -0
  46. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/formats/templates/epub/noindent.css +0 -0
  47. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo +0 -0
  48. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po +0 -0
  49. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/txt2ebook.pot +0 -0
  50. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo +0 -0
  51. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po +0 -0
  52. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo +0 -0
  53. {txt2ebook-0.1.119 → txt2ebook-0.1.123}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txt2ebook
3
- Version: 0.1.119
3
+ Version: 0.1.123
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
@@ -77,122 +77,57 @@ txt2ebook --help
77
77
  <!--help !-->
78
78
 
79
79
  ```console
80
- usage: txt2ebook [-of OUTPUT_FOLDER] [-p] [-f {epub,gmi,md,pdf,tex,txt,typ}]
81
- [-ik INDEX_KEYWORD] [-t TITLE] [-l LANGUAGE] [-a AUTHOR]
82
- [-tr TRANSLATOR] [-c IMAGE_FILENAME] [-w WIDTH]
83
- [-ff FILENAME_FORMAT] [-ps SEPARATOR] [-pz PAGE_SIZE]
84
- [-rd REGEX] [-rvc REGEX] [-rv REGEX] [-rc REGEX] [-rt REGEX]
85
- [-ra REGEX] [-rl REGEX] [-rr REGEX REGEX] [-ct]
86
- [-et {clean,condense,noindent}] [-vp] [-tp] [-sp] [-ss]
87
- [-toc] [-hn] [-fw] [-rw] [-ow] [-op] [-q] [-v] [-y] [-d]
88
- [--env] [-h] [-V]
89
- TXT_FILENAME [EBOOK_FILENAME]
80
+ usage: txt2ebook [-of OUTPUT_FOLDER] [-p] [-l LANGUAGE] [-rw] [-q] [-v] [-d]
81
+ [-h] [-V]
82
+ {env,epub,gmi,massage,md,parse,pdf,tex,typ} ...
90
83
 
91
84
  txt2ebook/tte is a cli tool to convert txt file to ebook format.
92
85
 
93
- website: https://github.com/kianmeng/txt2ebook
94
- changelog: https://github.com/kianmeng/txt2ebook/blob/master/CHANGELOG.md
95
- issues: https://github.com/kianmeng/txt2ebook/issues
86
+ website: https://github.com/kianmeng/txt2ebook
87
+ changelog: https://github.com/kianmeng/txt2ebook/blob/master/CHANGELOG.md
88
+ issues: https://github.com/kianmeng/txt2ebook/issues
96
89
 
97
90
  positional arguments:
98
- TXT_FILENAME
99
- source text filename
100
- EBOOK_FILENAME
101
- converted ebook filename (default: 'TXT_FILENAME.epub')
91
+ {env,epub,gmi,massage,md,parse,pdf,tex,typ}
92
+ sub-command help
93
+ env
94
+ print environment information for bug reporting
95
+ epub
96
+ generate ebook in EPUB format
97
+ gmi
98
+ generate ebook in Markdown format
99
+ massage
100
+ massage the source txt file
101
+ md
102
+ generate ebook in Markdown format
103
+ parse
104
+ parse and validate the txt file
105
+ pdf
106
+ generate ebook in Markdown format
107
+ tex
108
+ generate ebook in TeX/PDF format
109
+ typ
110
+ generate ebook in Typst format
102
111
 
103
112
  options:
104
- -of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER
113
+ -of, --output-folder OUTPUT_FOLDER
105
114
  set default output folder (default: 'output')
106
115
  -p, --purge
107
116
  remove converted ebooks specified by --output-folder option (default: 'False')
108
- -f {epub,gmi,md,pdf,tex,txt,typ}, --format {epub,gmi,md,pdf,tex,txt,typ}
109
- ebook format (default: 'epub')
110
- -ik INDEX_KEYWORD, --index-keyword INDEX_KEYWORD
111
- keyword to index (default: '[]')
112
- -t TITLE, --title TITLE
113
- title of the ebook (default: 'None')
114
- -l LANGUAGE, --language LANGUAGE
117
+ -l, --language LANGUAGE
115
118
  language of the ebook (default: 'None')
116
- -a AUTHOR, --author AUTHOR
117
- author of the ebook (default: '[]')
118
- -tr TRANSLATOR, --translator TRANSLATOR
119
- translator of the ebook (default: '[]')
120
- -ff FILENAME_FORMAT, --filename-format FILENAME_FORMAT
121
- the output filename format (default: TXT_FILENAME [EBOOK_FILENAME])
122
- 1 - title_authors.EBOOK_EXTENSION
123
- 2 - authors_title.EBOOK_EXTENSION
124
- -ps SEPARATOR, --paragraph_separator SEPARATOR
125
- paragraph separator (default: '\n\n')
126
- -rd REGEX, --regex-delete REGEX
127
- regex to delete word or phrase (default: '[]')
128
- -rvc REGEX, --regex-volume-chapter REGEX
129
- regex to parse volume and chapter header (default: by LANGUAGE)
130
- -rv REGEX, --regex-volume REGEX
131
- regex to parse volume header (default: by LANGUAGE)
132
- -rc REGEX, --regex-chapter REGEX
133
- regex to parse chapter header (default: by LANGUAGE)
134
- -rt REGEX, --regex-title REGEX
135
- regex to parse title of the book (default: by LANGUAGE)
136
- -ra REGEX, --regex-author REGEX
137
- regex to parse author of the book (default: by LANGUAGE)
138
- -rl REGEX, --regex-delete-line REGEX
139
- regex to delete whole line (default: '[]')
140
- -rr REGEX REGEX, --regex-replace REGEX REGEX
141
- regex to search and replace (default: '[]')
142
- -tp, --test-parsing
143
- test parsing for volume/chapter header
144
- -ss, --sort-volume-and-chapter
145
- short volume and chapter
146
119
  -rw, --raise-on-warning
147
120
  raise exception and stop parsing upon warning
148
- -ow, --overwrite
149
- overwrite massaged TXT_FILENAME
150
- -op, --open
151
- open the generated file using default program
152
121
  -q, --quiet
153
122
  suppress all logging
154
123
  -v, --verbose
155
124
  show verbosity of debugging log, use -vv, -vvv for more details
156
- -y, --yes
157
- yes to prompt
158
125
  -d, --debug
159
126
  show debugging log and stacktrace
160
- --env
161
- print environments information for bug reporting
162
127
  -h, --help
163
128
  show this help message and exit
164
129
  -V, --version
165
130
  show program's version number and exit
166
-
167
- --format epub:
168
- -c IMAGE_FILENAME, --cover IMAGE_FILENAME
169
- cover of the ebook
170
- -et {clean,condense,noindent}, --epub-template {clean,condense,noindent}
171
- CSS template for epub ebook (default: 'clean')
172
- -vp, --volume-page
173
- generate each volume as separate page
174
-
175
- --format pdf:
176
- -pz PAGE_SIZE, --page-size PAGE_SIZE
177
- page size of the ebook (default: 'a5')
178
-
179
- --format txt:
180
- -w WIDTH, --width WIDTH
181
- width for line wrapping
182
- -sp, --split-volume-and-chapter
183
- split volume or chapter into separate file and ignore the --overwrite option
184
- -toc, --table-of-content
185
- add table of content
186
-
187
- --format tex:
188
- -ct, --clean-tex
189
- purge artifacts generated by TeX (default: 'False')
190
-
191
- --language zh-cn / --language zh-tw:
192
- -hn, --header-number
193
- convert section header from words to numbers
194
- -fw, --fullwidth
195
- convert ASCII character from halfwidth to fullwidth
196
131
  ```
197
132
 
198
133
  <!--help !-->
@@ -205,7 +140,7 @@ txt2ebook ebook.txt
205
140
 
206
141
  ## Copyright and License
207
142
 
208
- Copyright (c) 2021,2022,2023,2024 Kian-Meng Ang
143
+ Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
209
144
 
210
145
  This program is free software: you can redistribute it and/or modify it under
211
146
  the terms of the GNU Affero General Public License as published by the Free
@@ -0,0 +1,116 @@
1
+ # txt2ebook
2
+
3
+ A console tool to convert txt file to different ebook formats.
4
+
5
+ ## Installation
6
+
7
+ Stable version From PyPI:
8
+
9
+ ```console
10
+ python3 -m pip install txt2ebook
11
+ ```
12
+
13
+ Upgrade to latest stable version:
14
+
15
+ ```console
16
+ python3 -m pip install txt2ebook --upgrade
17
+ ```
18
+
19
+ Latest development version from GitHub:
20
+
21
+ ```console
22
+ python3 -m pip install -e git+https://github.com/kianmeng/txt2ebook.git
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Showing help message of command-line options:
28
+
29
+ ```console
30
+ txt2ebook --help
31
+ ```
32
+
33
+ <!--help !-->
34
+
35
+ ```console
36
+ usage: txt2ebook [-of OUTPUT_FOLDER] [-p] [-l LANGUAGE] [-rw] [-q] [-v] [-d]
37
+ [-h] [-V]
38
+ {env,epub,gmi,massage,md,parse,pdf,tex,typ} ...
39
+
40
+ txt2ebook/tte is a cli tool to convert txt file to ebook format.
41
+
42
+ website: https://github.com/kianmeng/txt2ebook
43
+ changelog: https://github.com/kianmeng/txt2ebook/blob/master/CHANGELOG.md
44
+ issues: https://github.com/kianmeng/txt2ebook/issues
45
+
46
+ positional arguments:
47
+ {env,epub,gmi,massage,md,parse,pdf,tex,typ}
48
+ sub-command help
49
+ env
50
+ print environment information for bug reporting
51
+ epub
52
+ generate ebook in EPUB format
53
+ gmi
54
+ generate ebook in Markdown format
55
+ massage
56
+ massage the source txt file
57
+ md
58
+ generate ebook in Markdown format
59
+ parse
60
+ parse and validate the txt file
61
+ pdf
62
+ generate ebook in Markdown format
63
+ tex
64
+ generate ebook in TeX/PDF format
65
+ typ
66
+ generate ebook in Typst format
67
+
68
+ options:
69
+ -of, --output-folder OUTPUT_FOLDER
70
+ set default output folder (default: 'output')
71
+ -p, --purge
72
+ remove converted ebooks specified by --output-folder option (default: 'False')
73
+ -l, --language LANGUAGE
74
+ language of the ebook (default: 'None')
75
+ -rw, --raise-on-warning
76
+ raise exception and stop parsing upon warning
77
+ -q, --quiet
78
+ suppress all logging
79
+ -v, --verbose
80
+ show verbosity of debugging log, use -vv, -vvv for more details
81
+ -d, --debug
82
+ show debugging log and stacktrace
83
+ -h, --help
84
+ show this help message and exit
85
+ -V, --version
86
+ show program's version number and exit
87
+ ```
88
+
89
+ <!--help !-->
90
+
91
+ Convert a txt file into epub:
92
+
93
+ ```console
94
+ txt2ebook ebook.txt
95
+ ```
96
+
97
+ ## Copyright and License
98
+
99
+ Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
100
+
101
+ This program is free software: you can redistribute it and/or modify it under
102
+ the terms of the GNU Affero General Public License as published by the Free
103
+ Software Foundation, either version 3 of the License, or (at your option) any
104
+ later version.
105
+
106
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
107
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
108
+ PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
109
+
110
+ You should have received a copy of the GNU Affero General Public License along
111
+ with this program. If not, see <https://www.gnu.org/licenses/>.
112
+
113
+ The fish logo used in the documentation generated by Sphinx is a public domain
114
+ drawing of Troschel's parrotfish (Chlorurus troschelii Var. A.) from
115
+ <https://commons.wikimedia.org/entity/M18506436>.
116
+ 18506436>.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "txt2ebook"
3
- version = "0.1.119"
3
+ version = "0.1.123"
4
4
  description = "CLI tool to convert txt file to ebook format"
5
5
  authors = ["Kian-Meng Ang <kianmeng@cpan.org>"]
6
6
  license = "AGPL-3.0-or-later"
@@ -45,7 +45,7 @@ lxml = "^5.2.2"
45
45
  jieba = "^0.42.1"
46
46
 
47
47
  [tool.poetry.scripts]
48
- txt2ebook = 'txt2ebook.txt2ebook:main'
48
+ txt2ebook = 'txt2ebook.cli.main'
49
49
  tte = 'txt2ebook.cli:main'
50
50
 
51
51
  [tool.poetry.group.dev.dependencies]
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -24,7 +24,7 @@ import langdetect
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
26
 
27
- __version__ = "0.1.119"
27
+ __version__ = "0.1.123"
28
28
 
29
29
 
30
30
  def setup_logger(config: argparse.Namespace) -> None:
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -32,7 +32,7 @@ logger = logging.getLogger(__name__)
32
32
 
33
33
 
34
34
  def build_parser(
35
- args: Optional[Sequence[str]] = [],
35
+ _args: Optional[Sequence[str]] = None,
36
36
  ) -> argparse.ArgumentParser:
37
37
  """Build the CLI parser."""
38
38
  parser = argparse.ArgumentParser(
@@ -64,15 +64,6 @@ def build_parser(
64
64
  ),
65
65
  )
66
66
 
67
- parser.add_argument(
68
- "-t",
69
- "--title",
70
- dest="title",
71
- default=None,
72
- help="title of the ebook (default: '%(default)s')",
73
- metavar="TITLE",
74
- )
75
-
76
67
  parser.add_argument(
77
68
  "-l",
78
69
  "--language",
@@ -82,54 +73,6 @@ def build_parser(
82
73
  metavar="LANGUAGE",
83
74
  )
84
75
 
85
- parser.add_argument(
86
- "-a",
87
- "--author",
88
- dest="author",
89
- default=[],
90
- action="append",
91
- help="author of the ebook (default: '%(default)s')",
92
- metavar="AUTHOR",
93
- )
94
-
95
- parser.add_argument(
96
- "-tr",
97
- "--translator",
98
- dest="translator",
99
- default=[],
100
- action="append",
101
- help="translator of the ebook (default: '%(default)s')",
102
- metavar="TRANSLATOR",
103
- )
104
-
105
- parser.add_argument(
106
- "-fw",
107
- "--fullwidth",
108
- default=False,
109
- action="store_true",
110
- dest="fullwidth",
111
- help="convert ASCII character from halfwidth to fullwidth",
112
- )
113
-
114
- parser.add_argument(
115
- "-hn",
116
- "--header-number",
117
- default=False,
118
- action="store_true",
119
- dest="header_number",
120
- help="convert section header from words to numbers",
121
- )
122
-
123
- parser.add_argument(
124
- "-ps",
125
- "--paragraph_separator",
126
- dest="paragraph_separator",
127
- type=lambda value: value.encode("utf-8").decode("unicode_escape"),
128
- default="\n\n",
129
- help="paragraph separator (default: %(default)r)",
130
- metavar="SEPARATOR",
131
- )
132
-
133
76
  parser.add_argument(
134
77
  "-rw",
135
78
  "--raise-on-warning",
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -88,10 +88,10 @@ class Parser:
88
88
  Returns:
89
89
  str: The formatted section header.
90
90
  """
91
- if not self.config.header_number or self.config.language not in (
91
+ if hasattr(self.config, "header_number") and (not self.config.header_number or self.config.language not in (
92
92
  "zh-cn",
93
93
  "zh-tw",
94
- ):
94
+ )):
95
95
  return words
96
96
 
97
97
  # left pad the section number if found as halfwidth integer
@@ -112,7 +112,7 @@ class Parser:
112
112
 
113
113
  replaced_words = zh_words_to_numbers(words, length=length)
114
114
 
115
- if self.config.fullwidth:
115
+ if hasattr(self.config, "fullwidth") and self.config.fullwidth:
116
116
  replaced_words = zh_halfwidth_to_fullwidth(replaced_words)
117
117
 
118
118
  logger.debug(
@@ -216,13 +216,13 @@ class Parser:
216
216
  toc[-1].add_paragraph(token.value)
217
217
 
218
218
  # Use authors if set explicitly from command line.
219
- if self.config.author:
219
+ if hasattr(self.config, "author") and self.config.author:
220
220
  authors = self.config.author
221
221
 
222
- if self.config.title:
222
+ if hasattr(self.config, "title") and self.config.title:
223
223
  book_title = self.config.title
224
224
 
225
- if self.config.translator:
225
+ if hasattr(self.config, "translator") and self.config.translator:
226
226
  authors = self.config.translator
227
227
 
228
228
  logger.info("Found or set book title: %s", book_title)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
1
+ # Copyright (c) 2021,2022,2023,2024,2025 Kian-Meng Ang
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU Affero General Public License as published by
@@ -103,6 +103,16 @@ def build_subparser(subparsers) -> None:
103
103
  metavar="FILENAME_FORMAT",
104
104
  )
105
105
 
106
+ epub_parser.add_argument(
107
+ "-ps",
108
+ "--paragraph_separator",
109
+ dest="paragraph_separator",
110
+ type=lambda value: value.encode("utf-8").decode("unicode_escape"),
111
+ default="\n\n",
112
+ help="paragraph separator (default: %(default)r)",
113
+ metavar="SEPARATOR",
114
+ )
115
+
106
116
 
107
117
  def run(args: argparse.Namespace) -> None:
108
118
  """Run epub subcommand.