txt2ebook 0.1.131__py3-none-any.whl → 0.1.133__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/gmi.py CHANGED
@@ -84,7 +84,7 @@ class GmiWriter(BaseWriter):
84
84
  f"_{txt_filename.stem}"
85
85
  f"_{section.title}"
86
86
  f"_{chapter.title}"
87
- ".md"
87
+ ".gmi"
88
88
  )
89
89
  )
90
90
 
@@ -128,12 +128,12 @@ class GmiWriter(BaseWriter):
128
128
 
129
129
  with open(new_filename, "w", encoding="utf8") as file:
130
130
  logger.info("Generate GemText file: %s", new_filename.resolve())
131
- file.write(self._to_md())
131
+ file.write(self._to_gmi())
132
132
 
133
133
  if self.config.open:
134
134
  self._open_file(new_filename)
135
135
 
136
- def _to_md(self) -> str:
136
+ def _to_gmi(self) -> str:
137
137
  toc = self._to_toc("*", "# ") if self.config.with_toc else ""
138
138
  return self._to_metadata_txt() + toc + self._to_body_txt()
139
139
 
txt2ebook/formats/pdf.py CHANGED
@@ -147,7 +147,7 @@ class PdfWriter(BaseWriter):
147
147
  style.borderColor = "#000000"
148
148
 
149
149
  footer = Paragraph(f"{doc.page}", style=style)
150
- _width, _height = footer.wrap(doc.width, doc.bottomMargin)
150
+ footer.wrap(doc.width, doc.bottomMargin)
151
151
  footer.drawOn(canvas, doc.leftMargin, doc.bottomMargin - cm)
152
152
 
153
153
  canvas.restoreState()
txt2ebook/parser.py CHANGED
@@ -88,10 +88,10 @@ class Parser:
88
88
  Returns:
89
89
  str: The formatted section header.
90
90
  """
91
- if hasattr(self.config, "header_number") and (not self.config.header_number or self.config.language not in (
91
+ if not getattr(self.config, "header_number", False) 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
@@ -209,11 +209,12 @@ class Parser:
209
209
  toc.append(current_chapter)
210
210
 
211
211
  if token.type == "PARAGRAPH":
212
- if toc and isinstance(toc[-1], Volume):
213
- toc[-1].chapters[-1].add_paragraph(token.value)
212
+ if toc:
213
+ if isinstance(toc[-1], Volume):
214
+ toc[-1].chapters[-1].add_paragraph(token.value)
214
215
 
215
- if toc and isinstance(toc[-1], Chapter):
216
- toc[-1].add_paragraph(token.value)
216
+ if isinstance(toc[-1], Chapter):
217
+ toc[-1].add_paragraph(token.value)
217
218
 
218
219
  # Use authors if set explicitly from command line.
219
220
  if hasattr(self.config, "author") and self.config.author:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txt2ebook
3
- Version: 0.1.131
3
+ Version: 0.1.133
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
@@ -5,9 +5,9 @@ txt2ebook/exceptions.py,sha256=PT3m85PE5QopHHUfRwEQzp0kJ4AA9yjLO6V6lYC8WhQ,858
5
5
  txt2ebook/formats/__init__.py,sha256=yNF426_jHKNCKenKj1JTbOs22vEBuGScEk6TKhFaZUk,1716
6
6
  txt2ebook/formats/base.py,sha256=ODguJ7OBPXfRQLLeoL-G66NZihroXb4kG5-56ZrlygI,5819
7
7
  txt2ebook/formats/epub.py,sha256=IVz-FmYQlcChOw38YqfKy46bPVSIrHyxA_94iz06N3Y,6941
8
- txt2ebook/formats/gmi.py,sha256=qwNCcHh2LN4pEn0rDLpQFhLOPjLBgMU-E_dxWxewWbw,6788
8
+ txt2ebook/formats/gmi.py,sha256=kKyYzqS4NkucyhdBmT8cPEu6DGnNf95vVvXYdFnC6-s,6791
9
9
  txt2ebook/formats/md.py,sha256=9RWv_7cfXfAGC1MdYm0WTkjpgtXKQJTQjYOf0MqQmsc,6537
10
- txt2ebook/formats/pdf.py,sha256=xPsTAZ0UtDjKt2sTMKDnNLEMq6gSVNnxkK9XDlMhC9A,7281
10
+ txt2ebook/formats/pdf.py,sha256=tr_ozVlL976yo7Ggny71zjOwzSd6tSnHTl7mcsLII_g,7263
11
11
  txt2ebook/formats/templates/__init__.py,sha256=f3K7pJByNmmvu-wvziks6qb2QnnLmkDjUACXyw2s60E,760
12
12
  txt2ebook/formats/templates/epub/__init__.py,sha256=-XVLvnknTJTmQZY9UTH705vMcHgy56rQVRTusYawEZ4,766
13
13
  txt2ebook/formats/templates/epub/clean.css,sha256=AnEwMckzUSKcjKsDiWtJW1oaceuklt2tyuS1VbpVK1s,462
@@ -32,7 +32,7 @@ txt2ebook/models/__init__.py,sha256=Z3zClWLj08Q8HgaWV1RRgIKatEhIUfYBAVWm-j4m05w,
32
32
  txt2ebook/models/book.py,sha256=OkYg9ogOyH6mizP4qACTBTq4x6OAfY01gmaEzlerhLw,2788
33
33
  txt2ebook/models/chapter.py,sha256=6YvUDHzR6amGMZgkQl_xHWrYZUmlfpF7mnDLilG2BpA,1686
34
34
  txt2ebook/models/volume.py,sha256=koz1KfWjvGWLFbmGEQlZ23frsP93cDsuBMySYBHiXm8,1597
35
- txt2ebook/parser.py,sha256=ClcmWdFMSLfU-76vVnoHVAb6N7qYhCy6zmIwK0MPx9M,9006
35
+ txt2ebook/parser.py,sha256=fToC1LyOnPeQVjMasceVp2BSFwF9mfgyqa_3b3LAsY4,9005
36
36
  txt2ebook/subcommands/__init__.py,sha256=ldhzvsrMsR8lZmhZef77JFz0jValpV3pytFfwJSkjls,1146
37
37
  txt2ebook/subcommands/env.py,sha256=NoebfEzrxjfrUTUvOHc14euyvrAD0W4SfUrBQQycJR8,1541
38
38
  txt2ebook/subcommands/epub.py,sha256=JDDucrRiiQW1B7ycKz5zS1X5SMQZ82GBtlE2_SBYIdw,3507
@@ -45,8 +45,8 @@ txt2ebook/subcommands/tex.py,sha256=X6ZBfuAs_mcJe8PNjzoW339ecPynZduVbcCq0henjiA,
45
45
  txt2ebook/subcommands/typ.py,sha256=r4Xf7xSINbYfaIKkVzdyQDlUMWPvOIcbvOwC71spu6w,3682
46
46
  txt2ebook/tokenizer.py,sha256=H9AaZVmNP43L3ONvj58u_5weZAjFG9SzQSeS9upGN1U,9642
47
47
  txt2ebook/zh_utils.py,sha256=0Yq9r-JL4HntW68vFR6TBP9yQim1a07mfsh_sp-XmaE,4887
48
- txt2ebook-0.1.131.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
- txt2ebook-0.1.131.dist-info/METADATA,sha256=zCXiM7s9xQoFAyNmv5NU--hc_DeR98OxCwV0M7SML8c,4969
50
- txt2ebook-0.1.131.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
- txt2ebook-0.1.131.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
52
- txt2ebook-0.1.131.dist-info/RECORD,,
48
+ txt2ebook-0.1.133.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
+ txt2ebook-0.1.133.dist-info/METADATA,sha256=z_5Ki5IujWXMtuJzZV4Wz6Hl35mLSAq6vflyVzrV_qo,4969
50
+ txt2ebook-0.1.133.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
+ txt2ebook-0.1.133.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
52
+ txt2ebook-0.1.133.dist-info/RECORD,,