pyeasyphd 0.4.2__tar.gz → 0.4.24__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.
Potentially problematic release.
This version of pyeasyphd might be problematic. Click here for more details.
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/PKG-INFO +2 -3
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/main/basic_input.py +17 -17
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/main/pandoc_md_to.py +34 -32
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/main/python_run_md.py +33 -32
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/main/python_run_tex.py +17 -17
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/pyeasyphd.py +1 -1
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/pyeasyphd.sublime-settings +4 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/_base.py +15 -17
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_article_md.py +14 -11
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_article_tex.py +19 -15
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_beamer_tex.py +13 -12
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_compare.py +2 -4
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_format.py +2 -4
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_replace.py +3 -6
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_search.py +10 -16
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/generate/generate_from_bibs.py +23 -17
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/generate/generate_html.py +23 -19
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/generate/generate_library.py +27 -24
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/generate/generate_links.py +30 -31
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/py_run_bib_md_tex.py +40 -31
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/data.py +3 -3
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/search_base.py +12 -13
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/search_core.py +32 -29
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/search_keywords.py +6 -6
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/search_writers.py +29 -30
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/search/utils.py +9 -10
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/utils/utils.py +1 -2
- pyeasyphd-0.4.24/pyproject.toml +96 -0
- pyeasyphd-0.4.2/pyproject.toml +0 -67
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/LICENSE +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/README.md +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/.python-version +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/Main.sublime-menu +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/__init__.py +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/csl/apa-no-ampersand.csl +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/csl/apa.csl +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/csl/ieee.csl +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Article.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Article_Header.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Article_Tail.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Beamer_Header.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Beamer_Tail.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/Style.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/TEVC_Header.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/TEVC_Tail.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/eisvogel.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/math.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/math_commands.tex +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/data/templates/tex/nextaimathmacros.sty +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/main/__init__.py +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/pyeasyphd.sublime-syntax +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/__init__.py +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/scripts/run_generate.py +0 -0
- {pyeasyphd-0.4.2 → pyeasyphd-0.4.24}/pyeasyphd/tools/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyeasyphd
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.24
|
|
4
4
|
Summary: pyeasyphd
|
|
5
5
|
License: GPL-3.0-or-later
|
|
6
6
|
License-File: LICENSE
|
|
@@ -16,8 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist: pybibtexer (>=0.2.12,<0.3.0)
|
|
19
|
+
Requires-Dist: pybibtexer (>=0.3.13,<0.4.0)
|
|
21
20
|
Project-URL: Documentation, https://github.com/Easy-PhD/pyeasyphd
|
|
22
21
|
Project-URL: Homepage, https://github.com/Easy-PhD/pyeasyphd
|
|
23
22
|
Project-URL: Repository, https://github.com/Easy-PhD/pyeasyphd
|
|
@@ -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
|
|
|
@@ -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.
|
|
@@ -34,6 +33,7 @@ class PandocMdTo(BasicInput):
|
|
|
34
33
|
add_anchor_for_basic_dict (bool): Whether to add anchor for items in basic dict. Defaults to False.
|
|
35
34
|
add_anchor_for_beauty_dict (bool): Whether to add anchor for items in beauty dict. Defaults to False.
|
|
36
35
|
add_anchor_for_complex_dict (bool): Whether to add anchor for items in complex dict. Defaults to False.
|
|
36
|
+
details_to_bib_separator (str): Separator between <details> and bibliography content. Defaults to "\n".
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
def __init__(self, options: dict) -> None:
|
|
@@ -59,9 +59,11 @@ class PandocMdTo(BasicInput):
|
|
|
59
59
|
self.add_anchor_for_beauty_dict: bool = options.get("add_anchor_for_beauty_dict", False)
|
|
60
60
|
self.add_anchor_for_complex_dict: bool = options.get("add_anchor_for_complex_dict", False)
|
|
61
61
|
|
|
62
|
+
self.details_to_bib_separator: str = options.get("details_to_bib_separator", "\n")
|
|
63
|
+
|
|
62
64
|
def pandoc_md_to_md(
|
|
63
|
-
self, path_bib: str, path_md_one: str, path_md_two: str, name_md_one:
|
|
64
|
-
) ->
|
|
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]:
|
|
65
67
|
"""Convert markdown to markdown using pandoc.
|
|
66
68
|
|
|
67
69
|
Args:
|
|
@@ -72,13 +74,13 @@ class PandocMdTo(BasicInput):
|
|
|
72
74
|
name_md_two (Optional[str]): Name of destination markdown file.
|
|
73
75
|
|
|
74
76
|
Returns:
|
|
75
|
-
|
|
77
|
+
list[str]: list of processed markdown content lines.
|
|
76
78
|
"""
|
|
77
79
|
full_one = path_md_one if name_md_one is None else os.path.join(path_md_one, name_md_one)
|
|
78
80
|
full_two = path_md_two if name_md_two is None else os.path.join(path_md_two, name_md_two)
|
|
79
81
|
return self._pandoc_md_to_md(full_one, full_two, path_bib)
|
|
80
82
|
|
|
81
|
-
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]:
|
|
82
84
|
"""Internal method to convert markdown to markdown using pandoc.
|
|
83
85
|
|
|
84
86
|
Args:
|
|
@@ -87,7 +89,7 @@ class PandocMdTo(BasicInput):
|
|
|
87
89
|
path_bib (str): Path to bibliography file.
|
|
88
90
|
|
|
89
91
|
Returns:
|
|
90
|
-
|
|
92
|
+
list[str]: list of processed markdown content lines.
|
|
91
93
|
"""
|
|
92
94
|
if not os.path.exists(path_two := os.path.dirname(full_md_two)):
|
|
93
95
|
os.makedirs(path_two)
|
|
@@ -117,7 +119,7 @@ class PandocMdTo(BasicInput):
|
|
|
117
119
|
return self._standardize_markdown_content(full_md_two)
|
|
118
120
|
|
|
119
121
|
@staticmethod
|
|
120
|
-
def _standardize_markdown_content(full_md: str) ->
|
|
122
|
+
def _standardize_markdown_content(full_md: str) -> list[str]:
|
|
121
123
|
regex = re.compile(r"(\s*>*\s*[-+*]+)\s\s\s(.*)")
|
|
122
124
|
for i in range(len(data_list := read_list(full_md, "r"))):
|
|
123
125
|
if mch := regex.match(data_list[i]):
|
|
@@ -126,13 +128,13 @@ class PandocMdTo(BasicInput):
|
|
|
126
128
|
|
|
127
129
|
# for pandoc markdown files to tex files
|
|
128
130
|
def pandoc_md_to_tex(
|
|
129
|
-
self, template_name: str, path_md: str, path_tex: str, name_md:
|
|
130
|
-
) ->
|
|
131
|
+
self, template_name: str, path_md: str, path_tex: str, name_md: str | None, name_tex: str | None
|
|
132
|
+
) -> list[str]:
|
|
131
133
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
132
134
|
full_two = path_tex if name_tex is None else os.path.join(path_tex, name_tex)
|
|
133
135
|
return self._pandoc_md_to_tex(full_one, full_two, template_name)
|
|
134
136
|
|
|
135
|
-
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]:
|
|
136
138
|
"""Pandoc."""
|
|
137
139
|
if not os.path.exists(path_tex := os.path.dirname(full_tex)):
|
|
138
140
|
os.makedirs(path_tex)
|
|
@@ -153,7 +155,7 @@ class PandocMdTo(BasicInput):
|
|
|
153
155
|
|
|
154
156
|
return self._substitute_in_tex_from_md(read_list(full_tex, "r", None))
|
|
155
157
|
|
|
156
|
-
def _substitute_in_tex_from_md(self, data_list:
|
|
158
|
+
def _substitute_in_tex_from_md(self, data_list: list[str]) -> list[str]:
|
|
157
159
|
old_str_list = [r"{\[}@", r"{\[}-@", r"{\[}", r"{\]}", r"\\_"]
|
|
158
160
|
new_str_list = [rf"\\{self.cite_flag_in_tex}" + "{", rf"\\{self.cite_flag_in_tex}" + "{", "{", "}", "_"]
|
|
159
161
|
old_str_list.extend([r"\\footnote<.->{", r";", r"@"])
|
|
@@ -162,7 +164,7 @@ class PandocMdTo(BasicInput):
|
|
|
162
164
|
|
|
163
165
|
# for pandoc markdown files to html files
|
|
164
166
|
def pandoc_md_to_html(
|
|
165
|
-
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
|
|
166
168
|
) -> str:
|
|
167
169
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
168
170
|
full_two = path_html if name_html is None else os.path.join(path_html, name_html)
|
|
@@ -189,7 +191,7 @@ class PandocMdTo(BasicInput):
|
|
|
189
191
|
return ""
|
|
190
192
|
|
|
191
193
|
# for pandoc markdown files to pdf files
|
|
192
|
-
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:
|
|
193
195
|
full_one = path_md if name_md is None else os.path.join(path_md, name_md)
|
|
194
196
|
full_two = path_pdf if name_pdf is None else os.path.join(path_pdf, name_pdf)
|
|
195
197
|
return self._pandoc_md_to_pdf(full_one, full_two)
|
|
@@ -219,8 +221,8 @@ class PandocMdTo(BasicInput):
|
|
|
219
221
|
# --------- --------- --------- --------- --------- --------- --------- --------- --------- #
|
|
220
222
|
# md
|
|
221
223
|
def generate_key_data_dict(
|
|
222
|
-
self, pandoc_md_data_list:
|
|
223
|
-
) ->
|
|
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]]]:
|
|
224
226
|
"""Generate."""
|
|
225
227
|
key_reference_dict = self._generate_citation_key_reference_dict_from_pandoc_md(pandoc_md_data_list)
|
|
226
228
|
(key_basic_dict, key_beauty_dict, key_complex_dict) = self._generate_basic_beauty_complex_dict(
|
|
@@ -229,8 +231,8 @@ class PandocMdTo(BasicInput):
|
|
|
229
231
|
return key_basic_dict, key_beauty_dict, key_complex_dict
|
|
230
232
|
|
|
231
233
|
def _generate_citation_key_reference_dict_from_pandoc_md(
|
|
232
|
-
self, pandoc_md_data_list:
|
|
233
|
-
) ->
|
|
234
|
+
self, pandoc_md_data_list: list[str]
|
|
235
|
+
) -> dict[str, list[str]]:
|
|
234
236
|
"""Generate."""
|
|
235
237
|
pandoc_md_data_list = self.__append_pandoc_md_reference_part(pandoc_md_data_list)
|
|
236
238
|
|
|
@@ -266,7 +268,7 @@ class PandocMdTo(BasicInput):
|
|
|
266
268
|
key_reference_dict.update({citation_key: delete_empty_lines_last_occur_add_new_line(content)})
|
|
267
269
|
return key_reference_dict
|
|
268
270
|
|
|
269
|
-
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]:
|
|
270
272
|
"""Append the line which starts with '::: {#'."""
|
|
271
273
|
line_index, len_data = 0, len(pandoc_md_data_list)
|
|
272
274
|
if self.markdown_name == "pandoc-markdown":
|
|
@@ -293,15 +295,15 @@ class PandocMdTo(BasicInput):
|
|
|
293
295
|
return delete_empty_lines_last_occur_add_new_line(new_list)
|
|
294
296
|
|
|
295
297
|
def _generate_basic_beauty_complex_dict(
|
|
296
|
-
self, key_url_http_bib_dict:
|
|
297
|
-
) ->
|
|
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]]]:
|
|
298
300
|
"""Generate."""
|
|
299
|
-
header_list = ["<details
|
|
301
|
+
header_list = [f"<details>{self.details_to_bib_separator}", "```\n"]
|
|
300
302
|
tail_list = ["```\n", "</details>\n"]
|
|
301
303
|
|
|
302
|
-
key_basic_dict:
|
|
303
|
-
key_beauty_dict:
|
|
304
|
-
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]] = {}
|
|
305
307
|
|
|
306
308
|
key_list_http = list(key_url_http_bib_dict.keys())
|
|
307
309
|
key_list_md = list(key_reference_dict.keys())
|
|
@@ -310,10 +312,10 @@ class PandocMdTo(BasicInput):
|
|
|
310
312
|
return key_basic_dict, key_beauty_dict, key_complex_dict
|
|
311
313
|
|
|
312
314
|
for k in key_list_http:
|
|
313
|
-
a:
|
|
314
|
-
b:
|
|
315
|
-
aa:
|
|
316
|
-
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]
|
|
317
319
|
|
|
318
320
|
# add url
|
|
319
321
|
if self.add_url_for_basic_dict:
|
|
@@ -323,9 +325,9 @@ class PandocMdTo(BasicInput):
|
|
|
323
325
|
|
|
324
326
|
# add anchor
|
|
325
327
|
if self.add_anchor_for_basic_dict:
|
|
326
|
-
a = [f'<a id="{k.lower()}"></a>\n'
|
|
328
|
+
a = [f'<a id="{k.lower()}"></a>\n', *a]
|
|
327
329
|
if self.add_anchor_for_beauty_dict or self.add_anchor_for_complex_dict:
|
|
328
|
-
b = [f'<a id="{k.lower()}"></a>\n'
|
|
330
|
+
b = [f'<a id="{k.lower()}"></a>\n', *b]
|
|
329
331
|
|
|
330
332
|
if self.display_one_line_reference_note:
|
|
331
333
|
a = ["".join(a).replace("\n", " ").strip() + "\n"]
|
|
@@ -353,7 +355,7 @@ class PandocMdTo(BasicInput):
|
|
|
353
355
|
return None
|
|
354
356
|
|
|
355
357
|
@staticmethod
|
|
356
|
-
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]]:
|
|
357
359
|
if len(file_prefix) == 0:
|
|
358
360
|
file_prefix = "file_prefix"
|
|
359
361
|
|
|
@@ -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.
|
|
@@ -56,13 +55,14 @@ class PythonRunMd(BasicInput):
|
|
|
56
55
|
replace_by_basic_beauty_complex_in_md (str): Replace by basic, beauty, or complex format. Defaults to "beauty".
|
|
57
56
|
display_basic_beauty_complex_references_in_md (str): Display basic, beauty, or complex references. Defaults to "beauty".
|
|
58
57
|
add_anchor_in_md (bool): Whether add anchor in markdown. Defaults to False.
|
|
58
|
+
details_to_bib_separator (str): Separator between <details> and bibliography content. Defaults to "\n".
|
|
59
59
|
"""
|
|
60
60
|
|
|
61
|
-
def __init__(self, options:
|
|
61
|
+
def __init__(self, options: dict[str, Any]) -> None:
|
|
62
62
|
"""Initialize PythonRunMd with configuration options.
|
|
63
63
|
|
|
64
64
|
Args:
|
|
65
|
-
options (
|
|
65
|
+
options (dict[str, Any]): Configuration options.
|
|
66
66
|
"""
|
|
67
67
|
super().__init__(options)
|
|
68
68
|
|
|
@@ -77,6 +77,7 @@ class PythonRunMd(BasicInput):
|
|
|
77
77
|
"display_basic_beauty_complex_references_in_md", "beauty"
|
|
78
78
|
)
|
|
79
79
|
self.add_anchor_in_md: bool = options.get("add_anchor_in_md", False)
|
|
80
|
+
self.details_to_bib_separator: str = options.get("details_to_bib_separator", "\n")
|
|
80
81
|
|
|
81
82
|
# for md
|
|
82
83
|
self._pandoc_md_to = PandocMdTo(self.options)
|
|
@@ -90,28 +91,28 @@ class PythonRunMd(BasicInput):
|
|
|
90
91
|
def special_operate_for_md(
|
|
91
92
|
self,
|
|
92
93
|
path_output: str,
|
|
93
|
-
data_list_md:
|
|
94
|
+
data_list_md: list[str],
|
|
94
95
|
output_md_name: str,
|
|
95
96
|
full_bib_for_abbr: str,
|
|
96
97
|
full_bib_for_zotero: str,
|
|
97
98
|
template_name: str = "article",
|
|
98
99
|
generate_html: bool = False,
|
|
99
100
|
generate_tex: bool = True,
|
|
100
|
-
) ->
|
|
101
|
+
) -> tuple[list[str], list[str]]:
|
|
101
102
|
"""Perform special operations on markdown files.
|
|
102
103
|
|
|
103
104
|
Args:
|
|
104
105
|
path_output (str): Path to output directory.
|
|
105
|
-
data_list_md (
|
|
106
|
+
data_list_md (list[str]): list of markdown content lines.
|
|
106
107
|
output_md_name (str): Name of output markdown file.
|
|
107
108
|
full_bib_for_abbr (str): Path to abbreviated bibliography file.
|
|
108
109
|
full_bib_for_zotero (str): Path to Zotero bibliography file.
|
|
109
|
-
template_name (str
|
|
110
|
-
generate_html (bool
|
|
111
|
-
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.
|
|
112
113
|
|
|
113
114
|
Returns:
|
|
114
|
-
|
|
115
|
+
tuple[list[str], list[str]]: Tuple containing processed markdown and LaTeX content.
|
|
115
116
|
"""
|
|
116
117
|
path_temp = os.path.join(path_output, "{}".format(time.strftime("%Y_%m_%d_%H_%M_%S")))
|
|
117
118
|
if not os.path.exists(path_temp):
|
|
@@ -163,7 +164,7 @@ class PythonRunMd(BasicInput):
|
|
|
163
164
|
|
|
164
165
|
def _special_operate_for_md(
|
|
165
166
|
self, output_md_name: str, path_temp: str, full_bib_for_abbr: str, full_bib_for_zotero: str
|
|
166
|
-
) ->
|
|
167
|
+
) -> list[str]:
|
|
167
168
|
"""Perform special operations for markdown processing.
|
|
168
169
|
|
|
169
170
|
Args:
|
|
@@ -173,7 +174,7 @@ class PythonRunMd(BasicInput):
|
|
|
173
174
|
full_bib_for_zotero (str): Path to Zotero bibliography file.
|
|
174
175
|
|
|
175
176
|
Returns:
|
|
176
|
-
|
|
177
|
+
list[str]: list of processed markdown content lines.
|
|
177
178
|
"""
|
|
178
179
|
# pandoc markdown to markdown
|
|
179
180
|
n1 = "1_pandoc" + ".md"
|
|
@@ -262,7 +263,7 @@ class PythonRunMd(BasicInput):
|
|
|
262
263
|
bib_in_md = combine_content_in_list(
|
|
263
264
|
[
|
|
264
265
|
["## Bibliography\n\n"],
|
|
265
|
-
["<details
|
|
266
|
+
[f"<details>{self.details_to_bib_separator}"],
|
|
266
267
|
["```\n"],
|
|
267
268
|
temp_c,
|
|
268
269
|
["```\n"],
|
|
@@ -276,16 +277,16 @@ class PythonRunMd(BasicInput):
|
|
|
276
277
|
return content_md
|
|
277
278
|
|
|
278
279
|
@staticmethod
|
|
279
|
-
def _special_format(temp_list:
|
|
280
|
+
def _special_format(temp_list: list[str], space_one: str, space_two: str) -> list[str]:
|
|
280
281
|
"""Apply special formatting for alignment.
|
|
281
282
|
|
|
282
283
|
Args:
|
|
283
|
-
temp_list (
|
|
284
|
+
temp_list (list[str]): list of strings to format.
|
|
284
285
|
space_one (str): First space string.
|
|
285
286
|
space_two (str): Second space string.
|
|
286
287
|
|
|
287
288
|
Returns:
|
|
288
|
-
|
|
289
|
+
list[str]: Formatted list of strings.
|
|
289
290
|
"""
|
|
290
291
|
for j in range(len(temp_list) - 1):
|
|
291
292
|
if temp_list[j][-1] == "\n":
|
|
@@ -294,23 +295,23 @@ class PythonRunMd(BasicInput):
|
|
|
294
295
|
|
|
295
296
|
def _generate_content_md(
|
|
296
297
|
self,
|
|
297
|
-
key_basic_beauty_complex_dict:
|
|
298
|
-
key_in_md_tex:
|
|
299
|
-
main_part:
|
|
300
|
-
last_part:
|
|
301
|
-
bib_in_md:
|
|
302
|
-
) ->
|
|
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]:
|
|
303
304
|
"""Generate markdown content from various components.
|
|
304
305
|
|
|
305
306
|
Args:
|
|
306
|
-
key_basic_beauty_complex_dict (
|
|
307
|
-
key_in_md_tex (
|
|
308
|
-
main_part (
|
|
309
|
-
last_part (
|
|
310
|
-
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.
|
|
311
312
|
|
|
312
313
|
Returns:
|
|
313
|
-
|
|
314
|
+
list[str]: Generated markdown content.
|
|
314
315
|
"""
|
|
315
316
|
temp_b = []
|
|
316
317
|
if self.add_reference_in_md:
|
|
@@ -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:
|
|
@@ -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:
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"add_anchor_for_beauty_dict": false,
|
|
17
17
|
// true, false
|
|
18
18
|
"add_anchor_for_complex_dict": false,
|
|
19
|
+
// "\n" or "\n\n"
|
|
20
|
+
"details_to_bib_separator": "\n",
|
|
19
21
|
|
|
20
22
|
// for md file
|
|
21
23
|
// pyeasyphd/main/python_run_md.py
|
|
@@ -35,6 +37,8 @@
|
|
|
35
37
|
"display_basic_beauty_complex_references_in_md": "beauty",
|
|
36
38
|
// true, false
|
|
37
39
|
"add_anchor_in_md": false,
|
|
40
|
+
// "\n" or "\n\n"
|
|
41
|
+
// "details_to_bib_separator": "\n",
|
|
38
42
|
|
|
39
43
|
// for tex file
|
|
40
44
|
// pyeasyphd/main/python_run_tex.py
|