pyeasyphd 0.4.12__py3-none-any.whl → 0.4.14__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.
Potentially problematic release.
This version of pyeasyphd might be problematic. Click here for more details.
- pyeasyphd/main/basic_input.py +17 -17
- pyeasyphd/main/pandoc_md_to.py +30 -31
- pyeasyphd/main/python_run_md.py +30 -31
- pyeasyphd/main/python_run_tex.py +17 -17
- pyeasyphd/pyeasyphd.py +1 -1
- pyeasyphd/scripts/_base.py +15 -17
- pyeasyphd/scripts/run_article_md.py +12 -11
- pyeasyphd/scripts/run_article_tex.py +12 -12
- pyeasyphd/scripts/run_beamer_tex.py +12 -12
- pyeasyphd/scripts/run_compare.py +2 -4
- pyeasyphd/scripts/run_format.py +2 -4
- pyeasyphd/scripts/run_replace.py +3 -6
- pyeasyphd/scripts/run_search.py +10 -16
- pyeasyphd/tools/generate/generate_from_bibs.py +23 -17
- pyeasyphd/tools/generate/generate_html.py +20 -16
- pyeasyphd/tools/generate/generate_library.py +27 -24
- pyeasyphd/tools/generate/generate_links.py +30 -31
- pyeasyphd/tools/py_run_bib_md_tex.py +50 -31
- pyeasyphd/tools/search/data.py +3 -3
- pyeasyphd/tools/search/search_base.py +12 -13
- pyeasyphd/tools/search/search_core.py +32 -29
- pyeasyphd/tools/search/search_keywords.py +6 -6
- pyeasyphd/tools/search/search_writers.py +29 -30
- pyeasyphd/tools/search/utils.py +9 -10
- pyeasyphd/utils/utils.py +1 -2
- {pyeasyphd-0.4.12.dist-info → pyeasyphd-0.4.14.dist-info}/METADATA +2 -2
- pyeasyphd-0.4.14.dist-info/RECORD +53 -0
- pyeasyphd-0.4.12.dist-info/RECORD +0 -53
- {pyeasyphd-0.4.12.dist-info → pyeasyphd-0.4.14.dist-info}/WHEEL +0 -0
- {pyeasyphd-0.4.12.dist-info → pyeasyphd-0.4.14.dist-info}/licenses/LICENSE +0 -0
pyeasyphd/main/basic_input.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from pyadvtools import read_list
|
|
5
5
|
from pybibtexer.main import BasicInput as BasicInputInPyBibtexer
|
|
@@ -9,28 +9,28 @@ class BasicInput(BasicInputInPyBibtexer):
|
|
|
9
9
|
"""Basic input class for handling bibliography and template configurations.
|
|
10
10
|
|
|
11
11
|
Args:
|
|
12
|
-
options (
|
|
12
|
+
options (dict[str, Any]): Configuration options.
|
|
13
13
|
|
|
14
14
|
Attributes:
|
|
15
15
|
full_csl_style_pandoc (str): Full path to CSL style for pandoc.
|
|
16
16
|
full_tex_article_template_pandoc (str): Full path to tex article template for pandoc.
|
|
17
17
|
full_tex_beamer_template_pandoc (str): Full path to tex beamer template for pandoc.
|
|
18
|
-
article_template_tex (
|
|
19
|
-
article_template_header_tex (
|
|
20
|
-
article_template_tail_tex (
|
|
21
|
-
beamer_template_header_tex (
|
|
22
|
-
beamer_template_tail_tex (
|
|
23
|
-
math_commands_tex (
|
|
24
|
-
usepackages_tex (
|
|
18
|
+
article_template_tex (list[str]): Article template for LaTeX.
|
|
19
|
+
article_template_header_tex (list[str]): Article template header for LaTeX.
|
|
20
|
+
article_template_tail_tex (list[str]): Article template tail for LaTeX.
|
|
21
|
+
beamer_template_header_tex (list[str]): Beamer template header for LaTeX.
|
|
22
|
+
beamer_template_tail_tex (list[str]): Beamer template tail for LaTeX.
|
|
23
|
+
math_commands_tex (list[str]): LaTeX math commands.
|
|
24
|
+
usepackages_tex (list[str]): LaTeX usepackages.
|
|
25
25
|
handly_preamble (bool): Whether to handle preamble manually.
|
|
26
|
-
options (
|
|
26
|
+
options (dict[str, Any]): Configuration options.
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
|
-
def __init__(self, options:
|
|
29
|
+
def __init__(self, options: dict[str, Any]) -> None:
|
|
30
30
|
"""Initialize BasicInput with configuration options.
|
|
31
31
|
|
|
32
32
|
Args:
|
|
33
|
-
options (
|
|
33
|
+
options (dict[str, Any]): Configuration options dictionary.
|
|
34
34
|
"""
|
|
35
35
|
super().__init__(options)
|
|
36
36
|
|
|
@@ -43,11 +43,11 @@ class BasicInput(BasicInputInPyBibtexer):
|
|
|
43
43
|
|
|
44
44
|
self.options = options
|
|
45
45
|
|
|
46
|
-
def _initialize_pandoc_md_to(self, options:
|
|
46
|
+
def _initialize_pandoc_md_to(self, options: dict[str, Any]) -> None:
|
|
47
47
|
"""Initialize pandoc markdown to other formats configuration.
|
|
48
48
|
|
|
49
49
|
Args:
|
|
50
|
-
options (
|
|
50
|
+
options (dict[str, Any]): Configuration options.
|
|
51
51
|
"""
|
|
52
52
|
csl_name = options.get("csl_name", "apa-no-ampersand")
|
|
53
53
|
if not isinstance(csl_name, str):
|
|
@@ -61,11 +61,11 @@ class BasicInput(BasicInputInPyBibtexer):
|
|
|
61
61
|
|
|
62
62
|
self.article_template_tex = self._try_read_list("tex", "Article.tex")
|
|
63
63
|
|
|
64
|
-
def _initialize_python_run_tex(self, options:
|
|
64
|
+
def _initialize_python_run_tex(self, options: dict[str, Any]) -> None:
|
|
65
65
|
"""Initialize Python LaTeX processing configuration.
|
|
66
66
|
|
|
67
67
|
Args:
|
|
68
|
-
options (
|
|
68
|
+
options (dict[str, Any]): Configuration options.
|
|
69
69
|
"""
|
|
70
70
|
self.article_template_header_tex = self._try_read_list("tex", "Article_Header.tex")
|
|
71
71
|
self.article_template_tail_tex = self._try_read_list("tex", "Article_Tail.tex")
|
|
@@ -89,7 +89,7 @@ class BasicInput(BasicInputInPyBibtexer):
|
|
|
89
89
|
file_name (str): Name of the file to read.
|
|
90
90
|
|
|
91
91
|
Returns:
|
|
92
|
-
|
|
92
|
+
list[str]: list of lines from the file, or empty list if file cannot be read.
|
|
93
93
|
"""
|
|
94
94
|
path_file = os.path.join(self._path_templates, folder_name, file_name)
|
|
95
95
|
|
pyeasyphd/main/pandoc_md_to.py
CHANGED
|
@@ -3,7 +3,6 @@ import os
|
|
|
3
3
|
import re
|
|
4
4
|
import subprocess
|
|
5
5
|
import time
|
|
6
|
-
from typing import Dict, List, Optional, Tuple
|
|
7
6
|
|
|
8
7
|
from pyadvtools import (
|
|
9
8
|
combine_content_in_list,
|
|
@@ -19,7 +18,7 @@ from .basic_input import BasicInput
|
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
class PandocMdTo(BasicInput):
|
|
22
|
-
"""Pandoc markdown to various formats (md, tex, html, pdf).
|
|
21
|
+
r"""Pandoc markdown to various formats (md, tex, html, pdf).
|
|
23
22
|
|
|
24
23
|
Args:
|
|
25
24
|
options (dict): Configuration options.
|
|
@@ -63,8 +62,8 @@ class PandocMdTo(BasicInput):
|
|
|
63
62
|
self.details_to_bib_separator: str = options.get("details_to_bib_separator", "\n")
|
|
64
63
|
|
|
65
64
|
def pandoc_md_to_md(
|
|
66
|
-
self, path_bib: str, path_md_one: str, path_md_two: str, name_md_one:
|
|
67
|
-
) ->
|
|
65
|
+
self, path_bib: str, path_md_one: str, path_md_two: str, name_md_one: str | None, name_md_two: str | None
|
|
66
|
+
) -> list[str]:
|
|
68
67
|
"""Convert markdown to markdown using pandoc.
|
|
69
68
|
|
|
70
69
|
Args:
|
|
@@ -75,13 +74,13 @@ class PandocMdTo(BasicInput):
|
|
|
75
74
|
name_md_two (Optional[str]): Name of destination markdown file.
|
|
76
75
|
|
|
77
76
|
Returns:
|
|
78
|
-
|
|
77
|
+
list[str]: list of processed markdown content lines.
|
|
79
78
|
"""
|
|
80
79
|
full_one = path_md_one if name_md_one is None else os.path.join(path_md_one, name_md_one)
|
|
81
80
|
full_two = path_md_two if name_md_two is None else os.path.join(path_md_two, name_md_two)
|
|
82
81
|
return self._pandoc_md_to_md(full_one, full_two, path_bib)
|
|
83
82
|
|
|
84
|
-
def _pandoc_md_to_md(self, full_md_one: str, full_md_two: str, path_bib: str) ->
|
|
83
|
+
def _pandoc_md_to_md(self, full_md_one: str, full_md_two: str, path_bib: str) -> list[str]:
|
|
85
84
|
"""Internal method to convert markdown to markdown using pandoc.
|
|
86
85
|
|
|
87
86
|
Args:
|
|
@@ -90,7 +89,7 @@ class PandocMdTo(BasicInput):
|
|
|
90
89
|
path_bib (str): Path to bibliography file.
|
|
91
90
|
|
|
92
91
|
Returns:
|
|
93
|
-
|
|
92
|
+
list[str]: list of processed markdown content lines.
|
|
94
93
|
"""
|
|
95
94
|
if not os.path.exists(path_two := os.path.dirname(full_md_two)):
|
|
96
95
|
os.makedirs(path_two)
|
|
@@ -120,7 +119,7 @@ class PandocMdTo(BasicInput):
|
|
|
120
119
|
return self._standardize_markdown_content(full_md_two)
|
|
121
120
|
|
|
122
121
|
@staticmethod
|
|
123
|
-
def _standardize_markdown_content(full_md: str) ->
|
|
122
|
+
def _standardize_markdown_content(full_md: str) -> list[str]:
|
|
124
123
|
regex = re.compile(r"(\s*>*\s*[-+*]+)\s\s\s(.*)")
|
|
125
124
|
for i in range(len(data_list := read_list(full_md, "r"))):
|
|
126
125
|
if mch := regex.match(data_list[i]):
|
|
@@ -129,13 +128,13 @@ class PandocMdTo(BasicInput):
|
|
|
129
128
|
|
|
130
129
|
# for pandoc markdown files to tex files
|
|
131
130
|
def pandoc_md_to_tex(
|
|
132
|
-
self, template_name: str, path_md: str, path_tex: str, name_md:
|
|
133
|
-
) ->
|
|
131
|
+
self, template_name: str, path_md: str, path_tex: str, name_md: str | None, name_tex: str | None
|
|
132
|
+
) -> list[str]:
|
|
134
133
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
135
134
|
full_two = path_tex if name_tex is None else os.path.join(path_tex, name_tex)
|
|
136
135
|
return self._pandoc_md_to_tex(full_one, full_two, template_name)
|
|
137
136
|
|
|
138
|
-
def _pandoc_md_to_tex(self, full_md: str, full_tex: str, template_name: str) ->
|
|
137
|
+
def _pandoc_md_to_tex(self, full_md: str, full_tex: str, template_name: str) -> list[str]:
|
|
139
138
|
"""Pandoc."""
|
|
140
139
|
if not os.path.exists(path_tex := os.path.dirname(full_tex)):
|
|
141
140
|
os.makedirs(path_tex)
|
|
@@ -156,7 +155,7 @@ class PandocMdTo(BasicInput):
|
|
|
156
155
|
|
|
157
156
|
return self._substitute_in_tex_from_md(read_list(full_tex, "r", None))
|
|
158
157
|
|
|
159
|
-
def _substitute_in_tex_from_md(self, data_list:
|
|
158
|
+
def _substitute_in_tex_from_md(self, data_list: list[str]) -> list[str]:
|
|
160
159
|
old_str_list = [r"{\[}@", r"{\[}-@", r"{\[}", r"{\]}", r"\\_"]
|
|
161
160
|
new_str_list = [rf"\\{self.cite_flag_in_tex}" + "{", rf"\\{self.cite_flag_in_tex}" + "{", "{", "}", "_"]
|
|
162
161
|
old_str_list.extend([r"\\footnote<.->{", r";", r"@"])
|
|
@@ -165,7 +164,7 @@ class PandocMdTo(BasicInput):
|
|
|
165
164
|
|
|
166
165
|
# for pandoc markdown files to html files
|
|
167
166
|
def pandoc_md_to_html(
|
|
168
|
-
self, path_md: str, path_html: str, name_md:
|
|
167
|
+
self, path_md: str, path_html: str, name_md: str | None, name_html: str | None, operate: bool = False
|
|
169
168
|
) -> str:
|
|
170
169
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
171
170
|
full_two = path_html if name_html is None else os.path.join(path_html, name_html)
|
|
@@ -192,7 +191,7 @@ class PandocMdTo(BasicInput):
|
|
|
192
191
|
return ""
|
|
193
192
|
|
|
194
193
|
# for pandoc markdown files to pdf files
|
|
195
|
-
def pandoc_md_to_pdf(self, path_md: str, path_pdf: str, name_md:
|
|
194
|
+
def pandoc_md_to_pdf(self, path_md: str, path_pdf: str, name_md: str | None, name_pdf: str | None) -> str:
|
|
196
195
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
197
196
|
full_two = path_pdf if name_pdf is None else os.path.join(path_pdf, name_pdf)
|
|
198
197
|
return self._pandoc_md_to_pdf(full_one, full_two)
|
|
@@ -222,8 +221,8 @@ class PandocMdTo(BasicInput):
|
|
|
222
221
|
# --------- --------- --------- --------- --------- --------- --------- --------- --------- #
|
|
223
222
|
# md
|
|
224
223
|
def generate_key_data_dict(
|
|
225
|
-
self, pandoc_md_data_list:
|
|
226
|
-
) ->
|
|
224
|
+
self, pandoc_md_data_list: list[str], key_url_http_bib_dict: dict[str, list[list[str]]]
|
|
225
|
+
) -> tuple[dict[str, list[str]], dict[str, list[str]], dict[str, list[str]]]:
|
|
227
226
|
"""Generate."""
|
|
228
227
|
key_reference_dict = self._generate_citation_key_reference_dict_from_pandoc_md(pandoc_md_data_list)
|
|
229
228
|
(key_basic_dict, key_beauty_dict, key_complex_dict) = self._generate_basic_beauty_complex_dict(
|
|
@@ -232,8 +231,8 @@ class PandocMdTo(BasicInput):
|
|
|
232
231
|
return key_basic_dict, key_beauty_dict, key_complex_dict
|
|
233
232
|
|
|
234
233
|
def _generate_citation_key_reference_dict_from_pandoc_md(
|
|
235
|
-
self, pandoc_md_data_list:
|
|
236
|
-
) ->
|
|
234
|
+
self, pandoc_md_data_list: list[str]
|
|
235
|
+
) -> dict[str, list[str]]:
|
|
237
236
|
"""Generate."""
|
|
238
237
|
pandoc_md_data_list = self.__append_pandoc_md_reference_part(pandoc_md_data_list)
|
|
239
238
|
|
|
@@ -269,7 +268,7 @@ class PandocMdTo(BasicInput):
|
|
|
269
268
|
key_reference_dict.update({citation_key: delete_empty_lines_last_occur_add_new_line(content)})
|
|
270
269
|
return key_reference_dict
|
|
271
270
|
|
|
272
|
-
def __append_pandoc_md_reference_part(self, pandoc_md_data_list:
|
|
271
|
+
def __append_pandoc_md_reference_part(self, pandoc_md_data_list: list[str]) -> list[str]:
|
|
273
272
|
"""Append the line which starts with '::: {#'."""
|
|
274
273
|
line_index, len_data = 0, len(pandoc_md_data_list)
|
|
275
274
|
if self.markdown_name == "pandoc-markdown":
|
|
@@ -296,15 +295,15 @@ class PandocMdTo(BasicInput):
|
|
|
296
295
|
return delete_empty_lines_last_occur_add_new_line(new_list)
|
|
297
296
|
|
|
298
297
|
def _generate_basic_beauty_complex_dict(
|
|
299
|
-
self, key_url_http_bib_dict:
|
|
300
|
-
) ->
|
|
298
|
+
self, key_url_http_bib_dict: dict[str, list[list[str]]], key_reference_dict: dict[str, list]
|
|
299
|
+
) -> tuple[dict[str, list[str]], dict[str, list[str]], dict[str, list[str]]]:
|
|
301
300
|
"""Generate."""
|
|
302
301
|
header_list = [f"<details>{self.details_to_bib_separator}", "```\n"]
|
|
303
302
|
tail_list = ["```\n", "</details>\n"]
|
|
304
303
|
|
|
305
|
-
key_basic_dict:
|
|
306
|
-
key_beauty_dict:
|
|
307
|
-
key_complex_dict:
|
|
304
|
+
key_basic_dict: dict[str, list[str]] = {}
|
|
305
|
+
key_beauty_dict: dict[str, list[str]] = {}
|
|
306
|
+
key_complex_dict: dict[str, list[str]] = {}
|
|
308
307
|
|
|
309
308
|
key_list_http = list(key_url_http_bib_dict.keys())
|
|
310
309
|
key_list_md = list(key_reference_dict.keys())
|
|
@@ -313,10 +312,10 @@ class PandocMdTo(BasicInput):
|
|
|
313
312
|
return key_basic_dict, key_beauty_dict, key_complex_dict
|
|
314
313
|
|
|
315
314
|
for k in key_list_http:
|
|
316
|
-
a:
|
|
317
|
-
b:
|
|
318
|
-
aa:
|
|
319
|
-
bb:
|
|
315
|
+
a: list[str] = copy.deepcopy(key_reference_dict[k])
|
|
316
|
+
b: list[str] = copy.deepcopy(key_reference_dict[k])
|
|
317
|
+
aa: list[str] = key_url_http_bib_dict[k][0]
|
|
318
|
+
bb: list[str] = key_url_http_bib_dict[k][1]
|
|
320
319
|
|
|
321
320
|
# add url
|
|
322
321
|
if self.add_url_for_basic_dict:
|
|
@@ -326,9 +325,9 @@ class PandocMdTo(BasicInput):
|
|
|
326
325
|
|
|
327
326
|
# add anchor
|
|
328
327
|
if self.add_anchor_for_basic_dict:
|
|
329
|
-
a = [f'<a id="{k.lower()}"></a>\n'
|
|
328
|
+
a = [f'<a id="{k.lower()}"></a>\n', *a]
|
|
330
329
|
if self.add_anchor_for_beauty_dict or self.add_anchor_for_complex_dict:
|
|
331
|
-
b = [f'<a id="{k.lower()}"></a>\n'
|
|
330
|
+
b = [f'<a id="{k.lower()}"></a>\n', *b]
|
|
332
331
|
|
|
333
332
|
if self.display_one_line_reference_note:
|
|
334
333
|
a = ["".join(a).replace("\n", " ").strip() + "\n"]
|
|
@@ -356,7 +355,7 @@ class PandocMdTo(BasicInput):
|
|
|
356
355
|
return None
|
|
357
356
|
|
|
358
357
|
@staticmethod
|
|
359
|
-
def _generate_tex_content(file_prefix: str, add_tex_name: str, add_bib_name: str) ->
|
|
358
|
+
def _generate_tex_content(file_prefix: str, add_tex_name: str, add_bib_name: str) -> tuple[list[str], list[str]]:
|
|
360
359
|
if len(file_prefix) == 0:
|
|
361
360
|
file_prefix = "file_prefix"
|
|
362
361
|
|
pyeasyphd/main/python_run_md.py
CHANGED
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
import re
|
|
4
4
|
import shutil
|
|
5
5
|
import time
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
7
|
|
|
8
8
|
from pyadvtools import combine_content_in_list, delete_empty_lines_last_occur_add_new_line, read_list, write_list
|
|
9
9
|
from pybibtexer.bib.core import ConvertStrToLibrary
|
|
@@ -14,8 +14,7 @@ from .pandoc_md_to import PandocMdTo
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def batch_convert_citations(text):
|
|
17
|
-
"""
|
|
18
|
-
Process all citations in the text, including multiple citations in one bracket.
|
|
17
|
+
r"""Process all citations in the text, including multiple citations in one bracket.
|
|
19
18
|
|
|
20
19
|
Example: [@ref1; @ref2] -> <sup>[@ref1](#ref1)</sup><sup>[@ref2](#ref2)</sup>
|
|
21
20
|
"""
|
|
@@ -43,10 +42,10 @@ def batch_convert_citations(text):
|
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
class PythonRunMd(BasicInput):
|
|
46
|
-
"""Python markdown processing class.
|
|
45
|
+
r"""Python markdown processing class.
|
|
47
46
|
|
|
48
47
|
Args:
|
|
49
|
-
options (
|
|
48
|
+
options (dict[str, Any]): Configuration options.
|
|
50
49
|
|
|
51
50
|
Attributes:
|
|
52
51
|
delete_temp_generate_md (bool): Whether to delete temporary generated markdown files. Defaults to True.
|
|
@@ -59,11 +58,11 @@ class PythonRunMd(BasicInput):
|
|
|
59
58
|
details_to_bib_separator (str): Separator between <details> and bibliography content. Defaults to "\n".
|
|
60
59
|
"""
|
|
61
60
|
|
|
62
|
-
def __init__(self, options:
|
|
61
|
+
def __init__(self, options: dict[str, Any]) -> None:
|
|
63
62
|
"""Initialize PythonRunMd with configuration options.
|
|
64
63
|
|
|
65
64
|
Args:
|
|
66
|
-
options (
|
|
65
|
+
options (dict[str, Any]): Configuration options.
|
|
67
66
|
"""
|
|
68
67
|
super().__init__(options)
|
|
69
68
|
|
|
@@ -92,28 +91,28 @@ class PythonRunMd(BasicInput):
|
|
|
92
91
|
def special_operate_for_md(
|
|
93
92
|
self,
|
|
94
93
|
path_output: str,
|
|
95
|
-
data_list_md:
|
|
94
|
+
data_list_md: list[str],
|
|
96
95
|
output_md_name: str,
|
|
97
96
|
full_bib_for_abbr: str,
|
|
98
97
|
full_bib_for_zotero: str,
|
|
99
98
|
template_name: str = "article",
|
|
100
99
|
generate_html: bool = False,
|
|
101
100
|
generate_tex: bool = True,
|
|
102
|
-
) ->
|
|
101
|
+
) -> tuple[list[str], list[str]]:
|
|
103
102
|
"""Perform special operations on markdown files.
|
|
104
103
|
|
|
105
104
|
Args:
|
|
106
105
|
path_output (str): Path to output directory.
|
|
107
|
-
data_list_md (
|
|
106
|
+
data_list_md (list[str]): list of markdown content lines.
|
|
108
107
|
output_md_name (str): Name of output markdown file.
|
|
109
108
|
full_bib_for_abbr (str): Path to abbreviated bibliography file.
|
|
110
109
|
full_bib_for_zotero (str): Path to Zotero bibliography file.
|
|
111
|
-
template_name (str
|
|
112
|
-
generate_html (bool
|
|
113
|
-
generate_tex (bool
|
|
110
|
+
template_name (str): Name of template to use. Defaults to "article".
|
|
111
|
+
generate_html (bool): Whether to generate HTML. Defaults to False.
|
|
112
|
+
generate_tex (bool): Whether to generate LaTeX. Defaults to True.
|
|
114
113
|
|
|
115
114
|
Returns:
|
|
116
|
-
|
|
115
|
+
tuple[list[str], list[str]]: Tuple containing processed markdown and LaTeX content.
|
|
117
116
|
"""
|
|
118
117
|
path_temp = os.path.join(path_output, "{}".format(time.strftime("%Y_%m_%d_%H_%M_%S")))
|
|
119
118
|
if not os.path.exists(path_temp):
|
|
@@ -165,7 +164,7 @@ class PythonRunMd(BasicInput):
|
|
|
165
164
|
|
|
166
165
|
def _special_operate_for_md(
|
|
167
166
|
self, output_md_name: str, path_temp: str, full_bib_for_abbr: str, full_bib_for_zotero: str
|
|
168
|
-
) ->
|
|
167
|
+
) -> list[str]:
|
|
169
168
|
"""Perform special operations for markdown processing.
|
|
170
169
|
|
|
171
170
|
Args:
|
|
@@ -175,7 +174,7 @@ class PythonRunMd(BasicInput):
|
|
|
175
174
|
full_bib_for_zotero (str): Path to Zotero bibliography file.
|
|
176
175
|
|
|
177
176
|
Returns:
|
|
178
|
-
|
|
177
|
+
list[str]: list of processed markdown content lines.
|
|
179
178
|
"""
|
|
180
179
|
# pandoc markdown to markdown
|
|
181
180
|
n1 = "1_pandoc" + ".md"
|
|
@@ -278,16 +277,16 @@ class PythonRunMd(BasicInput):
|
|
|
278
277
|
return content_md
|
|
279
278
|
|
|
280
279
|
@staticmethod
|
|
281
|
-
def _special_format(temp_list:
|
|
280
|
+
def _special_format(temp_list: list[str], space_one: str, space_two: str) -> list[str]:
|
|
282
281
|
"""Apply special formatting for alignment.
|
|
283
282
|
|
|
284
283
|
Args:
|
|
285
|
-
temp_list (
|
|
284
|
+
temp_list (list[str]): list of strings to format.
|
|
286
285
|
space_one (str): First space string.
|
|
287
286
|
space_two (str): Second space string.
|
|
288
287
|
|
|
289
288
|
Returns:
|
|
290
|
-
|
|
289
|
+
list[str]: Formatted list of strings.
|
|
291
290
|
"""
|
|
292
291
|
for j in range(len(temp_list) - 1):
|
|
293
292
|
if temp_list[j][-1] == "\n":
|
|
@@ -296,23 +295,23 @@ class PythonRunMd(BasicInput):
|
|
|
296
295
|
|
|
297
296
|
def _generate_content_md(
|
|
298
297
|
self,
|
|
299
|
-
key_basic_beauty_complex_dict:
|
|
300
|
-
key_in_md_tex:
|
|
301
|
-
main_part:
|
|
302
|
-
last_part:
|
|
303
|
-
bib_in_md:
|
|
304
|
-
) ->
|
|
298
|
+
key_basic_beauty_complex_dict: dict[str, list[str]],
|
|
299
|
+
key_in_md_tex: list[str],
|
|
300
|
+
main_part: list[str],
|
|
301
|
+
last_part: list[str],
|
|
302
|
+
bib_in_md: list[str],
|
|
303
|
+
) -> list[str]:
|
|
305
304
|
"""Generate markdown content from various components.
|
|
306
305
|
|
|
307
306
|
Args:
|
|
308
|
-
key_basic_beauty_complex_dict (
|
|
309
|
-
key_in_md_tex (
|
|
310
|
-
main_part (
|
|
311
|
-
last_part (
|
|
312
|
-
bib_in_md (
|
|
307
|
+
key_basic_beauty_complex_dict (dict[str, list[str]]): dictionary of formatted references.
|
|
308
|
+
key_in_md_tex (list[str]): list of citation keys in markdown/LaTeX.
|
|
309
|
+
main_part (list[str]): Main content part.
|
|
310
|
+
last_part (list[str]): Last content part.
|
|
311
|
+
bib_in_md (list[str]): Bibliography content for markdown.
|
|
313
312
|
|
|
314
313
|
Returns:
|
|
315
|
-
|
|
314
|
+
list[str]: Generated markdown content.
|
|
316
315
|
"""
|
|
317
316
|
temp_b = []
|
|
318
317
|
if self.add_reference_in_md:
|
pyeasyphd/main/python_run_tex.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
import re
|
|
3
3
|
import shutil
|
|
4
4
|
import subprocess
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from pyadvtools import delete_files, insert_list_in_list, read_list, write_list
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ class PythonRunTex(BasicInput):
|
|
|
13
13
|
"""Python LaTeX processing class.
|
|
14
14
|
|
|
15
15
|
Args:
|
|
16
|
-
options (
|
|
16
|
+
options (dict[str, Any]): Configuration options.
|
|
17
17
|
|
|
18
18
|
Attributes:
|
|
19
19
|
run_latex (bool): Whether to run LaTeX compilation. Defaults to False.
|
|
@@ -21,11 +21,11 @@ class PythonRunTex(BasicInput):
|
|
|
21
21
|
delete_run_latex_cache (bool): Whether to delete LaTeX cache files. Defaults to True.
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
|
-
def __init__(self, options:
|
|
24
|
+
def __init__(self, options: dict[str, Any]) -> None:
|
|
25
25
|
"""Initialize PythonRunTex with configuration options.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
options (
|
|
28
|
+
options (dict[str, Any]): Configuration options.
|
|
29
29
|
"""
|
|
30
30
|
super().__init__(options)
|
|
31
31
|
|
|
@@ -34,11 +34,11 @@ class PythonRunTex(BasicInput):
|
|
|
34
34
|
self.run_latex: bool = options.get("run_latex", False)
|
|
35
35
|
self.pdflatex_xelatex: str = options.get("pdflatex_xelatex", "xelatex") # pdflatex, xelatex
|
|
36
36
|
self.delete_run_latex_cache: bool = options.get("delete_run_latex_cache", True)
|
|
37
|
-
self.latex_clean_file_types:
|
|
37
|
+
self.latex_clean_file_types: list[str] | None = options.get("latex_clean_file_types", None)
|
|
38
38
|
|
|
39
39
|
def generate_standard_tex_data_list(
|
|
40
40
|
self,
|
|
41
|
-
data_list_body:
|
|
41
|
+
data_list_body: list[str],
|
|
42
42
|
output_tex_name: str,
|
|
43
43
|
path_output: str,
|
|
44
44
|
figure_folder_name: str = "figs",
|
|
@@ -46,21 +46,21 @@ class PythonRunTex(BasicInput):
|
|
|
46
46
|
bib_folder_name: str = "bib",
|
|
47
47
|
bib_name: str = "abbr.bib",
|
|
48
48
|
template_name: str = "article",
|
|
49
|
-
) ->
|
|
49
|
+
) -> list[str]:
|
|
50
50
|
"""Generate standard LaTeX data list with proper formatting.
|
|
51
51
|
|
|
52
52
|
Args:
|
|
53
|
-
data_list_body (
|
|
53
|
+
data_list_body (list[str]): list of body content strings.
|
|
54
54
|
output_tex_name (str): Name of output LaTeX file.
|
|
55
55
|
path_output (str): Path to output directory.
|
|
56
|
-
figure_folder_name (str
|
|
57
|
-
tex_folder_name (str
|
|
58
|
-
bib_folder_name (str
|
|
59
|
-
bib_name (str
|
|
60
|
-
template_name (str
|
|
56
|
+
figure_folder_name (str): Name of figures folder. Defaults to "figs".
|
|
57
|
+
tex_folder_name (str): Name of LaTeX folder. Defaults to "tex".
|
|
58
|
+
bib_folder_name (str): Name of bibliography folder. Defaults to "bib".
|
|
59
|
+
bib_name (str): Name of bibliography file. Defaults to "abbr.bib".
|
|
60
|
+
template_name (str): Name of template to use. Defaults to "article".
|
|
61
61
|
|
|
62
62
|
Returns:
|
|
63
|
-
|
|
63
|
+
list[str]: list of processed LaTeX content strings.
|
|
64
64
|
"""
|
|
65
65
|
# for figures
|
|
66
66
|
for i in range(len(data_list_body)):
|
|
@@ -78,7 +78,7 @@ class PythonRunTex(BasicInput):
|
|
|
78
78
|
|
|
79
79
|
def _special_operate_tex(
|
|
80
80
|
self,
|
|
81
|
-
data_list_body:
|
|
81
|
+
data_list_body: list[str],
|
|
82
82
|
template_name: str,
|
|
83
83
|
output_tex_name: str,
|
|
84
84
|
path_output: str,
|
|
@@ -89,7 +89,7 @@ class PythonRunTex(BasicInput):
|
|
|
89
89
|
"""Perform special operations on LaTeX files.
|
|
90
90
|
|
|
91
91
|
Args:
|
|
92
|
-
data_list_body (
|
|
92
|
+
data_list_body (list[str]): list of body content strings.
|
|
93
93
|
template_name (str): Name of template to use.
|
|
94
94
|
output_tex_name (str): Name of output LaTeX file.
|
|
95
95
|
path_output (str): Path to output directory.
|
|
@@ -163,7 +163,7 @@ class PythonRunTex(BasicInput):
|
|
|
163
163
|
if self.run_latex:
|
|
164
164
|
if shutil.which("latexmk"):
|
|
165
165
|
os.chdir(path_output)
|
|
166
|
-
cmd = "latexmk -{} {}"
|
|
166
|
+
cmd = f"latexmk -{self.pdflatex_xelatex} {main_name}"
|
|
167
167
|
try:
|
|
168
168
|
subprocess.run(cmd.split(), check=True, capture_output=True, text=True)
|
|
169
169
|
except subprocess.CalledProcessError as e:
|
pyeasyphd/pyeasyphd.py
CHANGED
|
@@ -12,7 +12,7 @@ def delete_files(path_storage: str, extensions) -> None:
|
|
|
12
12
|
|
|
13
13
|
Args:
|
|
14
14
|
path_storage (str): Path to the storage directory.
|
|
15
|
-
extensions:
|
|
15
|
+
extensions: list of file extensions to delete.
|
|
16
16
|
"""
|
|
17
17
|
for name in os.listdir(path_storage):
|
|
18
18
|
for ext in extensions:
|
pyeasyphd/scripts/_base.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def expand_path(path: str) -> str:
|
|
@@ -13,20 +13,19 @@ def expand_paths(*paths):
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def build_base_options(
|
|
16
|
-
include_publisher_list:
|
|
17
|
-
include_abbr_list:
|
|
18
|
-
exclude_publisher_list:
|
|
19
|
-
exclude_abbr_list:
|
|
16
|
+
include_publisher_list: list[str],
|
|
17
|
+
include_abbr_list: list[str],
|
|
18
|
+
exclude_publisher_list: list[str],
|
|
19
|
+
exclude_abbr_list: list[str],
|
|
20
20
|
path_conf_j_jsons: str,
|
|
21
|
-
) ->
|
|
22
|
-
"""
|
|
23
|
-
Build options dictionary with common configuration.
|
|
21
|
+
) -> dict[str, Any]:
|
|
22
|
+
"""Build options dictionary with common configuration.
|
|
24
23
|
|
|
25
24
|
Args:
|
|
26
|
-
include_publisher_list:
|
|
27
|
-
include_abbr_list:
|
|
28
|
-
exclude_publisher_list:
|
|
29
|
-
exclude_abbr_list:
|
|
25
|
+
include_publisher_list: list of publishers to include
|
|
26
|
+
include_abbr_list: list of conference/journal abbreviations to include
|
|
27
|
+
exclude_publisher_list: list of publishers to exclude
|
|
28
|
+
exclude_abbr_list: list of conference/journal abbreviations to exclude
|
|
30
29
|
path_conf_j_jsons: Base path for conferences/journals JSON files
|
|
31
30
|
|
|
32
31
|
Returns:
|
|
@@ -45,14 +44,13 @@ def build_base_options(
|
|
|
45
44
|
|
|
46
45
|
|
|
47
46
|
def build_search_options(
|
|
48
|
-
print_on_screen: bool, search_year_list:
|
|
49
|
-
) ->
|
|
50
|
-
"""
|
|
51
|
-
Build search options dictionary with common configuration.
|
|
47
|
+
print_on_screen: bool, search_year_list: list[str], keywords_type: str, keywords_list_list: list[list[str]]
|
|
48
|
+
) -> dict[str, Any]:
|
|
49
|
+
"""Build search options dictionary with common configuration.
|
|
52
50
|
|
|
53
51
|
Args:
|
|
54
52
|
print_on_screen: Whether to display results on screen
|
|
55
|
-
search_year_list:
|
|
53
|
+
search_year_list: list of years to filter search results
|
|
56
54
|
keywords_type: Category name for search keywords
|
|
57
55
|
keywords_list_list: Nested list of search keywords
|
|
58
56
|
|
|
@@ -2,6 +2,8 @@ import os
|
|
|
2
2
|
|
|
3
3
|
from pyeasyphd.tools import PyRunBibMdTex
|
|
4
4
|
|
|
5
|
+
from ._base import expand_path
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
def run_article_md_daily_notes(
|
|
7
9
|
path_input_file: str,
|
|
@@ -11,12 +13,11 @@ def run_article_md_daily_notes(
|
|
|
11
13
|
path_conf_j_jsons: str,
|
|
12
14
|
options: dict,
|
|
13
15
|
) -> None:
|
|
14
|
-
"""
|
|
15
|
-
Run article markdown daily notes processing pipeline.
|
|
16
|
+
"""Run article markdown daily notes processing pipeline.
|
|
16
17
|
|
|
17
18
|
Args:
|
|
18
19
|
path_input_file (str): Path to input files directory
|
|
19
|
-
input_file_names (list[str]):
|
|
20
|
+
input_file_names (list[str]): list of input file names
|
|
20
21
|
path_output_file (str): Path to output directory
|
|
21
22
|
bib_path_or_file (str): Path to bibliography file or directory
|
|
22
23
|
path_conf_j_jsons (str): Path to conferences and journals JSON files directory
|
|
@@ -25,13 +26,13 @@ def run_article_md_daily_notes(
|
|
|
25
26
|
Returns:
|
|
26
27
|
None
|
|
27
28
|
"""
|
|
28
|
-
path_input_file =
|
|
29
|
-
path_output_file =
|
|
29
|
+
path_input_file = expand_path(path_input_file)
|
|
30
|
+
path_output_file = expand_path(path_output_file)
|
|
30
31
|
|
|
31
32
|
# Initialize default options with detailed descriptions
|
|
32
33
|
_options = {
|
|
33
|
-
"full_json_c":
|
|
34
|
-
"full_json_j":
|
|
34
|
+
"full_json_c": expand_path(os.path.join(path_conf_j_jsons, "conferences.json")),
|
|
35
|
+
"full_json_j": expand_path(os.path.join(path_conf_j_jsons, "journals.json")),
|
|
35
36
|
# figure options
|
|
36
37
|
"includegraphics_figs_directory": "",
|
|
37
38
|
"shutil_includegraphics_figs": False,
|
|
@@ -43,12 +44,12 @@ def run_article_md_daily_notes(
|
|
|
43
44
|
"add_link_to_fields_for_abbr": ["title"], # None, or ["title", "journal", "booktitle"]
|
|
44
45
|
"maximum_authors_for_abbr": 0, # 0, 1, 2, ...
|
|
45
46
|
"add_index_to_entries": False,
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"bib_name_for_abbr": "abbr.bib",
|
|
48
|
+
"bib_name_for_zotero": "zotero.bib",
|
|
49
|
+
"bib_name_for_save": "save.bib",
|
|
49
50
|
"bib_folder_name": "bibs", # "" or "bib" or "bibs" or "main"
|
|
50
51
|
"delete_original_bib_in_output_folder": True, # default is False
|
|
51
|
-
"bib_path_or_file":
|
|
52
|
+
"bib_path_or_file": expand_path(bib_path_or_file),
|
|
52
53
|
# tex options
|
|
53
54
|
"handly_preamble": False,
|
|
54
55
|
"final_output_main_tex_name": "main.tex",
|