pyeasyphd 0.2.9__py3-none-any.whl → 0.2.10__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.

@@ -32,6 +32,9 @@ class PandocMdTo(BasicInput):
32
32
  display_one_line_reference_note (bool): Whether to display one line reference note. Defaults to False.
33
33
  cite_flag_in_tex (str): Citation flag in LaTeX. Defaults to "cite".
34
34
  add_url_for_basic_dict (bool): Whether to add url for items in basic dict. Defualts to True.
35
+ add_anchor_for_basic_dict (bool): Whether to add anchor for items in basic dict. Defaults to False.
36
+ add_anchor_for_beauty_dict (bool): Whether to add anchor for items in beauty dict. Defaults to False.
37
+ add_anchor_for_complex_dict (bool): Whether to add anchor for items in complex dict. Defaults to False.
35
38
  """
36
39
 
37
40
  def __init__(self, options: dict) -> None:
@@ -54,6 +57,9 @@ class PandocMdTo(BasicInput):
54
57
  self.cite_flag_in_tex: str = options.get("cite_flag_in_tex", "cite")
55
58
 
56
59
  self.add_url_for_basic_dict: bool = options.get("add_url_for_basic_dict", True)
60
+ self.add_anchor_for_basic_dict: bool = options.get("add_anchor_for_basic_dict", False)
61
+ self.add_anchor_for_beauty_dict: bool = options.get("add_anchor_for_beauty_dict", False)
62
+ self.add_anchor_for_complex_dict: bool = options.get("add_anchor_for_complex_dict", False)
57
63
 
58
64
  def pandoc_md_to_md(
59
65
  self, path_bib: str, path_md_one: str, path_md_two: str, name_md_one: Optional[str], name_md_two: Optional[str]
@@ -314,11 +320,18 @@ class PandocMdTo(BasicInput):
314
320
  if (not self.google_connected_paper_scite) and aa:
315
321
  bb = [f"([www]({aa[0].strip()}))\n"]
316
322
 
323
+ # add url
317
324
  if self.add_url_for_basic_dict:
318
325
  a.extend(aa)
319
326
 
320
327
  b.extend(bb)
321
328
 
329
+ # add anchor
330
+ if self.add_anchor_for_basic_dict:
331
+ a = [f'<a id="{k.lower()}"></a>'] + a
332
+ if self.add_anchor_for_beauty_dict or self.add_anchor_for_complex_dict:
333
+ b = [f'<a id="{k.lower()}"></a>'] + b
334
+
322
335
  if self.display_one_line_reference_note:
323
336
  a = ["".join(a).replace("\n", " ").strip() + "\n"]
324
337
  b = ["".join(b).replace("\n", " ").strip() + "\n"]
@@ -13,6 +13,35 @@ from .basic_input import BasicInput
13
13
  from .pandoc_md_to import PandocMdTo
14
14
 
15
15
 
16
+ def batch_convert_citations(text):
17
+ """
18
+ Process all citations in the text, including multiple citations in one bracket.
19
+
20
+ Example: [@ref1; @ref2] -> <sup>[@ref1](#ref1)</sup><sup>[@ref2](#ref2)</sup>
21
+ """
22
+ # Match all citation patterns within square brackets
23
+ pattern = r'\[([^]]+)\]'
24
+
25
+ def process_citation(match):
26
+ citations = match.group(1)
27
+ # Split multiple citations (support semicolon or comma separation)
28
+ citation_list = re.split(r'[;,]', citations)
29
+
30
+ result = []
31
+ for citation in citation_list:
32
+ citation = citation.strip()
33
+ if citation.startswith('@'):
34
+ cite_id = citation[1:] # Remove the @ symbol
35
+ result.append(f'[{citation}](#{cite_id.lower()})')
36
+ else:
37
+ # Keep non-citation content in original format
38
+ result.append(f'[{citation}]')
39
+
40
+ return ''.join(result)
41
+
42
+ return re.sub(pattern, process_citation, text)
43
+
44
+
16
45
  class PythonRunMd(BasicInput):
17
46
  """Python markdown processing class.
18
47
 
@@ -26,6 +55,7 @@ class PythonRunMd(BasicInput):
26
55
  replace_cite_to_fullcite_in_md (bool): Whether to replace citations with full citations in markdown. Defaults to False.
27
56
  replace_by_basic_beauty_complex_in_md (str): Replace by basic, beauty, or complex format. Defaults to "beauty".
28
57
  display_basic_beauty_complex_references_in_md (str): Display basic, beauty, or complex references. Defaults to "beauty".
58
+ add_anchor_in_md (bool): Whether add anchor in markdown. Defaults to False.
29
59
  """
30
60
 
31
61
  def __init__(self, options: Dict[str, Any]) -> None:
@@ -46,6 +76,7 @@ class PythonRunMd(BasicInput):
46
76
  self.display_basic_beauty_complex_references_in_md: str = options.get(
47
77
  "display_basic_beauty_complex_references_in_md", "beauty"
48
78
  )
79
+ self.add_anchor_in_md: bool = options.get("add_anchor_in_md", False)
49
80
 
50
81
  # for md
51
82
  self._pandoc_md_to = PandocMdTo(self.options)
@@ -175,6 +206,9 @@ class PythonRunMd(BasicInput):
175
206
  continue
176
207
 
177
208
  content[i] = content[i].replace(mch.group(), mch.group(1) + "[" + mch.group(2) + "]")
209
+ # add anchor
210
+ if self.add_anchor_in_md:
211
+ content = [batch_convert_citations(line) for line in content]
178
212
  n2 = "2_generate" + ".md"
179
213
  write_list(content, n2, "w", path_temp)
180
214
 
@@ -11,6 +11,12 @@
11
11
  "cite_flag_in_tex": "cite",
12
12
  // true, false
13
13
  "add_url_for_basic_dict": true,
14
+ // true, false
15
+ "add_anchor_for_basic_dict": false,
16
+ // true, false
17
+ "add_anchor_for_beauty_dict": false,
18
+ // true, false
19
+ "add_anchor_for_complex_dict": false,
14
20
 
15
21
  // for md file
16
22
  // pyeasyphd/main/python_run_md.py
@@ -28,6 +34,8 @@
28
34
  "replace_by_basic_beauty_complex_in_md": "beauty",
29
35
  // basic, beauty, complex
30
36
  "display_basic_beauty_complex_references_in_md": "beauty",
37
+ // true, false
38
+ "add_anchor_in_md": false,
31
39
 
32
40
  // for tex file
33
41
  // pyeasyphd/main/python_run_tex.py
@@ -62,7 +62,11 @@ def run_article_md_daily_notes(
62
62
  "generate_tex": False,
63
63
 
64
64
  # md options
65
- "add_url_for_basic_dict": False, # True
65
+ "add_url_for_basic_dict": False, # default is True
66
+ "add_anchor_for_basic_dict": False, # default is False
67
+ "add_anchor_for_beauty_dict": True, # default is False
68
+ "add_anchor_for_complex_dict": False, # default is False
69
+
66
70
  "final_output_main_md_name": "main.md",
67
71
  "delete_temp_generate_md": True,
68
72
  "add_reference_in_md": True,
@@ -70,6 +74,7 @@ def run_article_md_daily_notes(
70
74
  "replace_cite_to_fullcite_in_md": True,
71
75
  "replace_by_basic_beauty_complex_in_md": "basic",
72
76
  "display_basic_beauty_complex_references_in_md": "beauty",
77
+ "add_anchor_in_md": True, # default is False
73
78
 
74
79
  "md_folder_name": "mds", # "" or "md" or "main"
75
80
  "delete_original_md_in_output_folder": True, # False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyeasyphd
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: pyeasyphd
5
5
  License: GPL-3.0-or-later
6
6
  License-File: LICENSE
@@ -19,13 +19,13 @@ pyeasyphd/data/Templates/TEX/math.tex,sha256=eDpuVcjIv-iugZXQRxKFTAyXujMZflTjKlD
19
19
  pyeasyphd/data/Templates/TEX/math_commands.tex,sha256=4bHrv5hFsvXRtOLdVqhPuHJFT9eKKje_My3YTnknJvQ,41391
20
20
  pyeasyphd/main/__init__.py,sha256=Y7K7DO_MZZlbtxt5oAnyYuCggN2f9tu4cRfpA3lPaiI,416
21
21
  pyeasyphd/main/basic_input.py,sha256=w_4sHS-gOmk7j5dDKQjU0fxXLO2eM3UkvR7o1urgeAg,4607
22
- pyeasyphd/main/pandoc_md_to.py,sha256=P3IDMfy43dV-8OJXJIHhzyWHGBQKDPSEoAFcGe76tA4,16387
23
- pyeasyphd/main/python_run_md.py,sha256=76wuw9tK0D9_hRpt42-GUAjanGSKHdNWw5QrBmiEwjQ,12636
22
+ pyeasyphd/main/pandoc_md_to.py,sha256=6ZdaXlH-dScO9pDNOaWxpTdCJRWkYXnJVK4fComxIFM,17295
23
+ pyeasyphd/main/python_run_md.py,sha256=cqleE-kBGyYdUZIdT3zU58gxDK6oHiRmfvtGEHLG4sA,13923
24
24
  pyeasyphd/main/python_run_tex.py,sha256=9Syu8qRjPXN3gEabfRUWxwTFBm_izIcB4yFhsz3QNs0,7672
25
25
  pyeasyphd/pyeasyphd.py,sha256=OAwbwq2rSXLSk2AoTAF8hmlOMRSRfvDn1Uqk-zkuqH8,3470
26
- pyeasyphd/pyeasyphd.sublime-settings,sha256=2-lm1UtKDiFCEZ_eUsnf3AEVNoP529v_TJ-TRoUGhSo,2905
26
+ pyeasyphd/pyeasyphd.sublime-settings,sha256=KcXx3DjyVf8UfnB4FP4u-jaTQU3Cuj24OvxGCZvXAsw,3135
27
27
  pyeasyphd/pyeasyphd.sublime-syntax,sha256=pXylbA-tye-K5dCTjEJLFVRqtY1T7AgWZ4laxo-dnaE,73
28
- pyeasyphd/scripts/run_article_md.py,sha256=6lOdDfvq10Bks19b_5hE3vuJwssgUIjhzzI-pWXHXeE,3656
28
+ pyeasyphd/scripts/run_article_md.py,sha256=RXDgyc3METP_ln7IUaNDmLfu0XlZkYqm0UIdsyO16zo,3916
29
29
  pyeasyphd/tools/__init__.py,sha256=u1MZu_JjVac3HhEmcSTwroS83UVu0W5Vspy3Wu_-GH8,496
30
30
  pyeasyphd/tools/generate/generate_from_bibs.py,sha256=Dp1MyADwIRb9qFTFOkMPJLaeeh7NBjuiSLBN7smP2eo,7640
31
31
  pyeasyphd/tools/generate/generate_html.py,sha256=JzUEqgTVCaFzd4hXTYUEf0cVSO1QRe0nVUS72W6oyyU,5349
@@ -39,7 +39,7 @@ pyeasyphd/tools/search/search_keywords.py,sha256=YCurXuoYeU1ftve0cb8Hcn_g2FXCXf7
39
39
  pyeasyphd/tools/search/search_writers.py,sha256=Dz6D8m17R7x8NT7_PCjwmzlq29AfUz-N6sjyCguDTo4,15702
40
40
  pyeasyphd/tools/search/utils.py,sha256=bo7xtIZu31dQvjol1lwyWq1t6ldbw28oondwK8VbAqk,7562
41
41
  pyeasyphd/utils/utils.py,sha256=kWxzzgNwz77K9Q7j-RKTaoPpxqiVLVtaBMMhLuEenwE,3128
42
- pyeasyphd-0.2.9.dist-info/METADATA,sha256=fSyP1_aQSE5_dm600mr-OEkVfpto4nm0LZCGlBmG8UE,985
43
- pyeasyphd-0.2.9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
44
- pyeasyphd-0.2.9.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
45
- pyeasyphd-0.2.9.dist-info/RECORD,,
42
+ pyeasyphd-0.2.10.dist-info/METADATA,sha256=4gIE0eQv9crrTzZyNSArpqMr0ITJ6zWphEFGDkDTfxA,986
43
+ pyeasyphd-0.2.10.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
44
+ pyeasyphd-0.2.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
45
+ pyeasyphd-0.2.10.dist-info/RECORD,,