txt2ebook 0.1.82__py3-none-any.whl → 0.1.84__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 +1 -1
- txt2ebook/formats/tex.py +55 -14
- txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po +10 -13
- txt2ebook/locales/txt2ebook.pot +10 -13
- txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po +10 -13
- txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po +10 -13
- txt2ebook/txt2ebook.py +9 -0
- {txt2ebook-0.1.82.dist-info → txt2ebook-0.1.84.dist-info}/METADATA +1 -1
- {txt2ebook-0.1.82.dist-info → txt2ebook-0.1.84.dist-info}/RECORD +12 -12
- {txt2ebook-0.1.82.dist-info → txt2ebook-0.1.84.dist-info}/LICENSE.md +0 -0
- {txt2ebook-0.1.82.dist-info → txt2ebook-0.1.84.dist-info}/WHEEL +0 -0
- {txt2ebook-0.1.82.dist-info → txt2ebook-0.1.84.dist-info}/entry_points.txt +0 -0
txt2ebook/__init__.py
CHANGED
txt2ebook/formats/tex.py
CHANGED
@@ -26,8 +26,7 @@ from pylatex import Document as Doc
|
|
26
26
|
from pylatex import NoEscape as NoEsc
|
27
27
|
from pylatex import Package as Pkg
|
28
28
|
from pylatex.section import Chapter as Chap
|
29
|
-
from pylatex.section import
|
30
|
-
from pylatex.section import Part as Part
|
29
|
+
from pylatex.section import Part
|
31
30
|
|
32
31
|
from txt2ebook.formats.base import BaseWriter
|
33
32
|
from txt2ebook.models import Chapter, Volume
|
@@ -52,40 +51,82 @@ class TexWriter(BaseWriter):
|
|
52
51
|
|
53
52
|
doc = Doc(documentclass="ctexbook", document_options=[self._fontset()])
|
54
53
|
|
55
|
-
doc.packages.append(Pkg("geometry", options=["
|
56
|
-
doc.
|
54
|
+
doc.packages.append(Pkg("geometry", options=["a6paper"]))
|
55
|
+
doc.packages.append(Pkg("makeidx"))
|
56
|
+
doc.packages.append(
|
57
|
+
Pkg(
|
58
|
+
"idxlayout",
|
59
|
+
options=[
|
60
|
+
"columns=1",
|
61
|
+
"font=footnotesize",
|
62
|
+
"itemlayout=singlepar",
|
63
|
+
"indentunit=0pt",
|
64
|
+
],
|
65
|
+
)
|
66
|
+
)
|
67
|
+
doc.packages.append(
|
68
|
+
Pkg("hyperref", options=["colorlinks=true", "linktocpage=true"])
|
69
|
+
)
|
70
|
+
|
71
|
+
hide_section_seq = (
|
72
|
+
r"chapter/name={},chapter/number={},part/name={},part/number={}"
|
73
|
+
)
|
74
|
+
doc.preamble.append(Cmd("ctexset", NoEsc(hide_section_seq)))
|
57
75
|
doc.preamble.append(Cmd("title", self.book.title))
|
58
76
|
doc.preamble.append(Cmd("author", ", ".join(self.book.authors)))
|
59
|
-
doc.preamble.append(
|
77
|
+
doc.preamble.append(NoEsc(r"\date{}"))
|
78
|
+
doc.preamble.append(Cmd("makeindex"))
|
60
79
|
|
61
80
|
doc.append(NoEsc(r"\maketitle"))
|
62
81
|
doc.append(NoEsc(r"\thispagestyle{empty}"))
|
82
|
+
doc.append(NoEsc(r"\addtocontents{toc}{\protect\pagestyle{empty}}"))
|
83
|
+
doc.append(
|
84
|
+
NoEsc(r"\addtocontents{toc}{\protect\thispagestyle{empty}}")
|
85
|
+
)
|
86
|
+
doc.append(NoEsc(r"\tableofcontents"))
|
87
|
+
doc.append(NoEsc(r"\pagestyle{empty}"))
|
88
|
+
doc.append(NoEsc(r"\cleardoublepage"))
|
89
|
+
doc.append(NoEsc(r"\pagenumbering{arabic}"))
|
90
|
+
doc.append(NoEsc(r"\pagestyle{headings}"))
|
63
91
|
|
64
92
|
for section in self.book.toc:
|
65
93
|
if isinstance(section, Volume):
|
66
|
-
with doc.create(Part(section.title)):
|
94
|
+
with doc.create(Part(section.title, label=False)):
|
67
95
|
for chapter in section.chapters:
|
68
|
-
with doc.create(Chap(chapter.title)):
|
96
|
+
with doc.create(Chap(chapter.title, label=False)):
|
69
97
|
for paragraph in chapter.paragraphs:
|
70
|
-
|
98
|
+
par = paragraph.strip()
|
99
|
+
for keyword in self.config.index_keyword:
|
100
|
+
par = par.replace(
|
101
|
+
keyword, rf"\index{{{keyword}}}"
|
102
|
+
)
|
103
|
+
doc.append(NoEsc(rf"\par{{{par}}}"))
|
104
|
+
|
71
105
|
if isinstance(section, Chapter):
|
72
|
-
with doc.create(Chap(section.title)):
|
106
|
+
with doc.create(Chap(section.title, label=False)):
|
73
107
|
for paragraph in section.paragraphs:
|
74
|
-
|
108
|
+
par = paragraph.strip()
|
109
|
+
for keyword in self.config.index_keyword:
|
110
|
+
par = par.replace(keyword, rf"\index{{{keyword}}}")
|
111
|
+
doc.append(NoEsc(rf"\par{{{par}}}"))
|
112
|
+
|
113
|
+
doc.append(Cmd("printindex"))
|
75
114
|
|
76
115
|
filename = str(new_filename.parent / new_filename.stem)
|
77
116
|
pdf_filename = Path(filename).with_suffix(".pdf")
|
78
|
-
doc.generate_pdf(filename, compiler="
|
117
|
+
doc.generate_pdf(filename, compiler="latexmk", clean_tex=False)
|
79
118
|
|
80
119
|
if self.config.open:
|
81
120
|
self._open_file(pdf_filename)
|
82
121
|
|
83
122
|
def _fontset(self) -> str:
|
84
123
|
if sys.platform == "linux":
|
85
|
-
return "fontset
|
124
|
+
return "fontset=ubuntu"
|
86
125
|
|
87
126
|
if sys.platform == "darwin":
|
88
|
-
return "fontset
|
127
|
+
return "fontset=macos"
|
89
128
|
|
90
129
|
if sys.platform == "windows":
|
91
|
-
return "fontset
|
130
|
+
return "fontset=windows"
|
131
|
+
|
132
|
+
return "fontset=ubuntu"
|
@@ -1,34 +1,31 @@
|
|
1
|
-
#:
|
1
|
+
#: src/txt2ebook/formats/base.py:141
|
2
2
|
msgid "title:"
|
3
3
|
msgstr "Title:"
|
4
4
|
|
5
|
-
#:
|
5
|
+
#: src/txt2ebook/formats/base.py:142
|
6
6
|
msgid "author:"
|
7
7
|
msgstr "Author:"
|
8
8
|
|
9
|
-
#:
|
9
|
+
#: src/txt2ebook/formats/base.py:143
|
10
10
|
msgid "translator:"
|
11
11
|
msgstr "Translator:"
|
12
12
|
|
13
|
-
#:
|
13
|
+
#: src/txt2ebook/formats/base.py:144
|
14
14
|
msgid "tag:"
|
15
15
|
msgstr "Tag:"
|
16
16
|
|
17
|
-
#:
|
18
|
-
#:
|
19
|
-
#:
|
20
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/pdf.py:130
|
21
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:71
|
17
|
+
#: src/txt2ebook/formats/base.py:155 src/txt2ebook/formats/gmi.py:62
|
18
|
+
#: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
|
19
|
+
#: src/txt2ebook/formats/txt.py:71
|
22
20
|
msgid "toc"
|
23
21
|
msgstr "Table of Content"
|
24
22
|
|
25
|
-
#:
|
23
|
+
#: src/txt2ebook/formats/epub.py:147
|
26
24
|
msgid "cover"
|
27
25
|
msgstr "Cover"
|
28
26
|
|
29
|
-
#:
|
30
|
-
#:
|
31
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:56
|
27
|
+
#: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
|
28
|
+
#: src/txt2ebook/formats/txt.py:56
|
32
29
|
msgid "metadata"
|
33
30
|
msgstr "Metadata"
|
34
31
|
|
txt2ebook/locales/txt2ebook.pot
CHANGED
@@ -1,34 +1,31 @@
|
|
1
|
-
#:
|
1
|
+
#: src/txt2ebook/formats/base.py:141
|
2
2
|
msgid "title:"
|
3
3
|
msgstr ""
|
4
4
|
|
5
|
-
#:
|
5
|
+
#: src/txt2ebook/formats/base.py:142
|
6
6
|
msgid "author:"
|
7
7
|
msgstr ""
|
8
8
|
|
9
|
-
#:
|
9
|
+
#: src/txt2ebook/formats/base.py:143
|
10
10
|
msgid "translator:"
|
11
11
|
msgstr ""
|
12
12
|
|
13
|
-
#:
|
13
|
+
#: src/txt2ebook/formats/base.py:144
|
14
14
|
msgid "tag:"
|
15
15
|
msgstr ""
|
16
16
|
|
17
|
-
#:
|
18
|
-
#:
|
19
|
-
#:
|
20
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/pdf.py:130
|
21
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:71
|
17
|
+
#: src/txt2ebook/formats/base.py:155 src/txt2ebook/formats/gmi.py:62
|
18
|
+
#: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
|
19
|
+
#: src/txt2ebook/formats/txt.py:71
|
22
20
|
msgid "toc"
|
23
21
|
msgstr ""
|
24
22
|
|
25
|
-
#:
|
23
|
+
#: src/txt2ebook/formats/epub.py:147
|
26
24
|
msgid "cover"
|
27
25
|
msgstr ""
|
28
26
|
|
29
|
-
#:
|
30
|
-
#:
|
31
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:56
|
27
|
+
#: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
|
28
|
+
#: src/txt2ebook/formats/txt.py:56
|
32
29
|
msgid "metadata"
|
33
30
|
msgstr ""
|
34
31
|
|
@@ -1,34 +1,31 @@
|
|
1
|
-
#:
|
1
|
+
#: src/txt2ebook/formats/base.py:141
|
2
2
|
msgid "title:"
|
3
3
|
msgstr "书名:"
|
4
4
|
|
5
|
-
#:
|
5
|
+
#: src/txt2ebook/formats/base.py:142
|
6
6
|
msgid "author:"
|
7
7
|
msgstr "作者:"
|
8
8
|
|
9
|
-
#:
|
9
|
+
#: src/txt2ebook/formats/base.py:143
|
10
10
|
msgid "translator:"
|
11
11
|
msgstr "翻译:"
|
12
12
|
|
13
|
-
#:
|
13
|
+
#: src/txt2ebook/formats/base.py:144
|
14
14
|
msgid "tag:"
|
15
15
|
msgstr "票签:"
|
16
16
|
|
17
|
-
#:
|
18
|
-
#:
|
19
|
-
#:
|
20
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/pdf.py:130
|
21
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:71
|
17
|
+
#: src/txt2ebook/formats/base.py:155 src/txt2ebook/formats/gmi.py:62
|
18
|
+
#: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
|
19
|
+
#: src/txt2ebook/formats/txt.py:71
|
22
20
|
msgid "toc"
|
23
21
|
msgstr "目录"
|
24
22
|
|
25
|
-
#:
|
23
|
+
#: src/txt2ebook/formats/epub.py:147
|
26
24
|
msgid "cover"
|
27
25
|
msgstr "封面"
|
28
26
|
|
29
|
-
#:
|
30
|
-
#:
|
31
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:56
|
27
|
+
#: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
|
28
|
+
#: src/txt2ebook/formats/txt.py:56
|
32
29
|
msgid "metadata"
|
33
30
|
msgstr "元数据"
|
34
31
|
|
@@ -1,34 +1,31 @@
|
|
1
|
-
#:
|
1
|
+
#: src/txt2ebook/formats/base.py:141
|
2
2
|
msgid "title:"
|
3
3
|
msgstr "书名:"
|
4
4
|
|
5
|
-
#:
|
5
|
+
#: src/txt2ebook/formats/base.py:142
|
6
6
|
msgid "author:"
|
7
7
|
msgstr "作者:"
|
8
8
|
|
9
|
-
#:
|
9
|
+
#: src/txt2ebook/formats/base.py:143
|
10
10
|
msgid "translator:"
|
11
11
|
msgstr "翻译:"
|
12
12
|
|
13
|
-
#:
|
13
|
+
#: src/txt2ebook/formats/base.py:144
|
14
14
|
msgid "tag:"
|
15
15
|
msgstr "标签:"
|
16
16
|
|
17
|
-
#:
|
18
|
-
#:
|
19
|
-
#:
|
20
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/pdf.py:130
|
21
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:71
|
17
|
+
#: src/txt2ebook/formats/base.py:155 src/txt2ebook/formats/gmi.py:62
|
18
|
+
#: src/txt2ebook/formats/md.py:61 src/txt2ebook/formats/pdf.py:130
|
19
|
+
#: src/txt2ebook/formats/txt.py:71
|
22
20
|
msgid "toc"
|
23
21
|
msgstr "目录"
|
24
22
|
|
25
|
-
#:
|
23
|
+
#: src/txt2ebook/formats/epub.py:147
|
26
24
|
msgid "cover"
|
27
25
|
msgstr "封面"
|
28
26
|
|
29
|
-
#:
|
30
|
-
#:
|
31
|
-
#: /home/ang/src/self/txt2ebook/txt2ebook/src/txt2ebook/formats/txt.py:56
|
27
|
+
#: src/txt2ebook/formats/gmi.py:47 src/txt2ebook/formats/md.py:46
|
28
|
+
#: src/txt2ebook/formats/txt.py:56
|
32
29
|
msgid "metadata"
|
33
30
|
msgstr "元数据"
|
34
31
|
|
txt2ebook/txt2ebook.py
CHANGED
@@ -155,6 +155,15 @@ def build_parser(
|
|
155
155
|
help="ebook format (default: 'epub')",
|
156
156
|
)
|
157
157
|
|
158
|
+
parser.add_argument(
|
159
|
+
"-ik",
|
160
|
+
"--index-keyword",
|
161
|
+
dest="index_keyword",
|
162
|
+
action="append",
|
163
|
+
default=[],
|
164
|
+
help="keyword to index (default: '%(default)s')",
|
165
|
+
)
|
166
|
+
|
158
167
|
parser.add_argument(
|
159
168
|
"-t",
|
160
169
|
"--title",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
txt2ebook/__init__.py,sha256=
|
1
|
+
txt2ebook/__init__.py,sha256=zMFL-NYSvFdf8dYeqaHHtJZFtyCYEgHChq6IJ_BSefE,2061
|
2
2
|
txt2ebook/__main__.py,sha256=gMLvgpqc_BL4cBqNe0vqErRF5dlJPAbvqu1zndcAHYI,850
|
3
3
|
txt2ebook/exceptions.py,sha256=b2HDsXdqweLJbvSJEGt48nxvGkZq20SfYezSjwp77JU,842
|
4
4
|
txt2ebook/formats/__init__.py,sha256=WhiRWGvbUjc8QZfhAIkKCg6GL8vNNlEF73meZSzYhDA,2463
|
@@ -12,7 +12,7 @@ txt2ebook/formats/templates/epub/__init__.py,sha256=DeIsL4WDqgTU7zCLxlCidFItvG4N
|
|
12
12
|
txt2ebook/formats/templates/epub/clean.css,sha256=AnEwMckzUSKcjKsDiWtJW1oaceuklt2tyuS1VbpVK1s,462
|
13
13
|
txt2ebook/formats/templates/epub/condense.css,sha256=Fz80ZqkPsFRmGdURduAxqMV8drD0CCUlrv41P8rUsm8,477
|
14
14
|
txt2ebook/formats/templates/epub/noindent.css,sha256=_O5Tv90TKyyPBRdgjuNKFwtKFbdheh2V9PtDhgRUg3U,483
|
15
|
-
txt2ebook/formats/tex.py,sha256=
|
15
|
+
txt2ebook/formats/tex.py,sha256=0TviJ7MagHQ2kyghCXiylHV_9bOR3QTaGr1aghggA1M,5063
|
16
16
|
txt2ebook/formats/txt.py,sha256=8PkJ54r-0saZYyYEH64nYSkM-oW5LnurCbAk6d2Ue78,7536
|
17
17
|
txt2ebook/formats/typ.py,sha256=79WQyaexmNVJ0Xh7ykNjpwcS0vK7sdkSlrOBm-uV6dA,5200
|
18
18
|
txt2ebook/helpers/__init__.py,sha256=cQmFjEsEEI0gRxDPL-284FMS5Z-iBMcu-4qe7Icf7is,1971
|
@@ -21,22 +21,22 @@ txt2ebook/languages/en.py,sha256=LVZsvr6JLbQFrfI1XSYG54mFwzlHa0fhKghlUemkQbo,920
|
|
21
21
|
txt2ebook/languages/zh_cn.py,sha256=_3DnB7mDW_EJW3-jy9ZfnxIZ85zNgfXqzPoc7daBHIY,1930
|
22
22
|
txt2ebook/languages/zh_tw.py,sha256=ISjDXJes-jbOUC_5RDH8Bsc0ttBf-4Dt2HNDEBxwRgE,1464
|
23
23
|
txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo,sha256=Ym6soeijV3zsv9FUPWlJnu18-CNb5tcOTN5JsMOfV9c,672
|
24
|
-
txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po,sha256=
|
25
|
-
txt2ebook/locales/txt2ebook.pot,sha256=
|
24
|
+
txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po,sha256=cXhuoliGo0pP3nYQZ9oVBr9KlZoH3rObT3InvYrcFt0,698
|
25
|
+
txt2ebook/locales/txt2ebook.pot,sha256=7Kx5R2IajWqXlTwvG9aTILzpnodLKeONlGBbaHW2-no,641
|
26
26
|
txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo,sha256=rRGW7HByDVZV8WpQkhyIFOWYNTQc4NnStrn0eGJX8Wc,675
|
27
|
-
txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po,sha256=
|
27
|
+
txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po,sha256=D01adM7HEKkFzlKu-6eBG0LhN5KDXcMny-ajV8kkumo,698
|
28
28
|
txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo,sha256=1GIuOcO_bISiFcfhFez-A7mSi11Mo-x3PBobBENgMEc,675
|
29
|
-
txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po,sha256=
|
29
|
+
txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po,sha256=JN6iot1G9roKZi7FkB6kXSZYg3uR6wBBUoRrmF8aKRk,698
|
30
30
|
txt2ebook/models/__init__.py,sha256=8_k1oI_PnPMekhdZCXiTtg5WghdR6fugQEHJHsy1-Ds,925
|
31
31
|
txt2ebook/models/book.py,sha256=GYXvklHnLIuodEgbjzulyA0OSX72K37ohGBn8xDwCgw,2759
|
32
32
|
txt2ebook/models/chapter.py,sha256=buECAklNQgM3tDehzyVO9YfA_F0iXyLq2PaMZGV_Zaw,1681
|
33
33
|
txt2ebook/models/volume.py,sha256=HyT4XO9yZ8d0PgZVfMMyAYUDFv58RrUmsSFNNmU-sHY,1592
|
34
34
|
txt2ebook/parser.py,sha256=vdC--8I2c89xve7OA1OkYTDjSMwwKoyv4Wkmca0iFhE,11823
|
35
35
|
txt2ebook/tokenizer.py,sha256=y1CQ3Xf5g74o_mUZSOwrwwu0grKmgmt6x3yxCWWokhU,9318
|
36
|
-
txt2ebook/txt2ebook.py,sha256=
|
36
|
+
txt2ebook/txt2ebook.py,sha256=O9YG6k5vDSRFpawc2iVRmi7uNxP89GrSR68D1mGepHc,13419
|
37
37
|
txt2ebook/zh_utils.py,sha256=EgKVbwqYGaTGswQUGcOCeSfRelzwkAb9WWY9TrsX1x4,4882
|
38
|
-
txt2ebook-0.1.
|
39
|
-
txt2ebook-0.1.
|
40
|
-
txt2ebook-0.1.
|
41
|
-
txt2ebook-0.1.
|
42
|
-
txt2ebook-0.1.
|
38
|
+
txt2ebook-0.1.84.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
|
39
|
+
txt2ebook-0.1.84.dist-info/METADATA,sha256=zJkKdu3X5ZGyZ0wItPVlA15sAWk93qdsD-sTq1UOG08,7511
|
40
|
+
txt2ebook-0.1.84.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
41
|
+
txt2ebook-0.1.84.dist-info/entry_points.txt,sha256=IQHyIIhd0MHjSSRVC1a6tMeIoLus8D06KHL_cumvEbg,83
|
42
|
+
txt2ebook-0.1.84.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|