txt2ebook 0.1.138__py3-none-any.whl → 0.1.139__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/formats/typ.py CHANGED
@@ -113,8 +113,11 @@ class TypWriter(BaseWriter):
113
113
  ]
114
114
 
115
115
  #set par(
116
- first-line-indent: 2em,
117
- justify: true
116
+ first-line-indent: (
117
+ amount: 2em,
118
+ all:true,
119
+ ),
120
+ justify: true,
118
121
  )
119
122
 
120
123
  #set text(
txt2ebook/parser.py CHANGED
@@ -35,8 +35,8 @@ logger = logging.getLogger(__name__)
35
35
  class Parser:
36
36
  """Parser class to massage and parse a text content."""
37
37
 
38
- raw_content: str = field()
39
- config: argparse.Namespace = field()
38
+ raw_content: str
39
+ config: argparse.Namespace
40
40
 
41
41
  def __init__(self, raw_content: str, config: argparse.Namespace) -> None:
42
42
  """Set the constructor for the Parser."""
txt2ebook/tokenizer.py CHANGED
@@ -171,12 +171,27 @@ class Tokenizer:
171
171
 
172
172
 
173
173
  def _tokenize_content(self) -> None:
174
- # TODO: split by metadata and content
175
- content = self.raw_content.split(f"{self.metadata_marker}\n\n")[1]
176
- content = content.strip(self.config.paragraph_separator)
177
- lines = content.split(self.config.paragraph_separator)
174
+ # Determine the actual content part, after any metadata block
175
+ metadata_block_re = (
176
+ rf"^(?:{self.metadata_marker})\n(.*)\n(?:{self.metadata_marker})$"
177
+ )
178
+ match = re.search(
179
+ metadata_block_re, self.raw_content, re.MULTILINE | re.DOTALL
180
+ )
178
181
 
179
- if len(lines) <= 1:
182
+ if match:
183
+ # Content starts after the matched metadata block
184
+ content_str = self.raw_content[match.end(0) :]
185
+ else:
186
+ # No metadata block found according to the pattern,
187
+ # so assume all raw_content is the actual content.
188
+ # _extract_metadata would have already logged/warned if metadata was expected.
189
+ content_str = self.raw_content
190
+
191
+ content_str = content_str.strip(self.config.paragraph_separator)
192
+ lines = content_str.split(self.config.paragraph_separator)
193
+
194
+ if len(lines) <= 1 and content_str: # Avoid warning for empty content
180
195
  msg = (
181
196
  "Cannot split content by "
182
197
  f"{repr(self.config.paragraph_separator)}. "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txt2ebook
3
- Version: 0.1.138
3
+ Version: 0.1.139
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
@@ -38,7 +38,7 @@ Requires-Dist: pypandoc~=1.11
38
38
  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
- Requires-Dist: typst<0.13,>=0.12.0
41
+ Requires-Dist: typst>=0.13.0
42
42
  Description-Content-Type: text/markdown
43
43
 
44
44
  # txt2ebook
@@ -2,8 +2,8 @@ txt2ebook/__init__.py,sha256=wnrJownTB3sKXv3BpcXn4exkpWRSCXhKYWKJib5APNI,3073
2
2
  txt2ebook/__main__.py,sha256=L29rlfPSx9XMnVaHBYP2dyYgDmutJvONR3yUejjYwRY,855
3
3
  txt2ebook/cli.py,sha256=X91GnzdSTZI4Cl2ttskMmQpBy6QuyENuX_VnwOHtA7Q,4423
4
4
  txt2ebook/exceptions.py,sha256=PT3m85PE5QopHHUfRwEQzp0kJ4AA9yjLO6V6lYC8WhQ,858
5
- txt2ebook/parser.py,sha256=IOSTbkvLQ9Uvo1hUBDTKozMQagA547N3qr-xU8aE0RI,9009
6
- txt2ebook/tokenizer.py,sha256=H9AaZVmNP43L3ONvj58u_5weZAjFG9SzQSeS9upGN1U,9642
5
+ txt2ebook/parser.py,sha256=Crtx8_c85j8LPYAmJlsI7631vKuw0wx-8S1Q_H9u4Dw,8989
6
+ txt2ebook/tokenizer.py,sha256=CEmIcindFG1hUrdYn1_RCYOhJEpwkY2NGzZCBmSEAHY,10300
7
7
  txt2ebook/zh_utils.py,sha256=0Yq9r-JL4HntW68vFR6TBP9yQim1a07mfsh_sp-XmaE,4887
8
8
  txt2ebook/formats/__init__.py,sha256=yNF426_jHKNCKenKj1JTbOs22vEBuGScEk6TKhFaZUk,1716
9
9
  txt2ebook/formats/base.py,sha256=ODguJ7OBPXfRQLLeoL-G66NZihroXb4kG5-56ZrlygI,5819
@@ -13,7 +13,7 @@ txt2ebook/formats/md.py,sha256=9RWv_7cfXfAGC1MdYm0WTkjpgtXKQJTQjYOf0MqQmsc,6537
13
13
  txt2ebook/formats/pdf.py,sha256=tr_ozVlL976yo7Ggny71zjOwzSd6tSnHTl7mcsLII_g,7263
14
14
  txt2ebook/formats/tex.py,sha256=V5B1nPR-WzGc4jqWu-BqxfQhtQsUTKM_sZZJsCcDBAk,5897
15
15
  txt2ebook/formats/txt.py,sha256=j5RWF41WQfLdm-APwi8u-OE8snenDEJLzxHD_i9mxeg,7541
16
- txt2ebook/formats/typ.py,sha256=_a3PKFh5jlHvaqRes6XvtPoDJI_HJaH7pCBbBRFeYyM,6647
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
19
  txt2ebook/formats/templates/epub/clean.css,sha256=AnEwMckzUSKcjKsDiWtJW1oaceuklt2tyuS1VbpVK1s,462
@@ -45,8 +45,8 @@ txt2ebook/subcommands/parse.py,sha256=FaYTWa2yqkowwPAmHWJC7iCii2Rnus3SUHG10GjjJp
45
45
  txt2ebook/subcommands/pdf.py,sha256=KS3rzxPJG6ovt8GPJj8u1Bum5ye3zrEI0LPz21EMLZo,2981
46
46
  txt2ebook/subcommands/tex.py,sha256=X6ZBfuAs_mcJe8PNjzoW339ecPynZduVbcCq0henjiA,3131
47
47
  txt2ebook/subcommands/typ.py,sha256=r4Xf7xSINbYfaIKkVzdyQDlUMWPvOIcbvOwC71spu6w,3682
48
- txt2ebook-0.1.138.dist-info/METADATA,sha256=G7pFnLaDciAOsy4QaboVHeT6_MGWvIwvEWnLBviBt-A,4873
49
- txt2ebook-0.1.138.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
- txt2ebook-0.1.138.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
51
- txt2ebook-0.1.138.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
52
- txt2ebook-0.1.138.dist-info/RECORD,,
48
+ txt2ebook-0.1.139.dist-info/METADATA,sha256=-j5Q8uMTzj2N8bCv3dJtYFF4Ij5snzy4vxvueu6FK8o,4867
49
+ txt2ebook-0.1.139.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
+ txt2ebook-0.1.139.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
51
+ txt2ebook-0.1.139.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
52
+ txt2ebook-0.1.139.dist-info/RECORD,,