chatgpt-md-converter 0.1.1__py3-none-any.whl → 0.1.2__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.
@@ -16,6 +16,7 @@ def split_by_tag(out_text: str, md_tag: str, html_tag: str) -> str:
16
16
  Splits the text by markdown tag and replaces it with the specified HTML tag.
17
17
  """
18
18
  tag_pattern = re.compile(
19
- r"{}(.*?){}".format(re.escape(md_tag), re.escape(md_tag)), re.DOTALL
19
+ r"(?<!\w){}(.*?){}(?!\w)".format(re.escape(md_tag), re.escape(md_tag)),
20
+ re.DOTALL,
20
21
  )
21
22
  return tag_pattern.sub(r"<{}>\1</{}>".format(html_tag, html_tag), out_text)
@@ -1,9 +1,6 @@
1
- import re
2
-
3
-
4
1
  def combine_blockquotes(text: str) -> str:
5
2
  """
6
- Combines multiline blockquotes into a single blockquote.
3
+ Combines multiline blockquotes into a single blockquote while keeping the \n characters.
7
4
  """
8
5
  lines = text.split("\n")
9
6
  combined_lines = []
@@ -17,7 +14,7 @@ def combine_blockquotes(text: str) -> str:
17
14
  else:
18
15
  if in_blockquote:
19
16
  combined_lines.append(
20
- "<blockquote>" + " ".join(blockquote_lines) + "</blockquote>"
17
+ "<blockquote>" + "\n".join(blockquote_lines) + "</blockquote>"
21
18
  )
22
19
  blockquote_lines = []
23
20
  in_blockquote = False
@@ -25,7 +22,7 @@ def combine_blockquotes(text: str) -> str:
25
22
 
26
23
  if in_blockquote:
27
24
  combined_lines.append(
28
- "<blockquote>" + " ".join(blockquote_lines) + "</blockquote>"
25
+ "<blockquote>" + "\n".join(blockquote_lines) + "</blockquote>"
29
26
  )
30
27
 
31
28
  return "\n".join(combined_lines)
@@ -26,6 +26,7 @@ def telegram_format(text: str) -> str:
26
26
 
27
27
  # Nested Bold and Italic
28
28
  output = re.sub(r"\*\*\*(.*?)\*\*\*", r"<b><i>\1</i></b>", output)
29
+ output = re.sub(r"\_\_\_(.*?)\_\_\_", r"<u><i>\1</i></u>", output)
29
30
 
30
31
  # Process markdown formatting tags (bold, underline, italic, strikethrough)
31
32
  # and convert them to their respective HTML tags
@@ -39,14 +40,14 @@ def telegram_format(text: str) -> str:
39
40
  output = re.sub(r"【[^】]+】", "", output)
40
41
 
41
42
  # Convert links
42
- output = re.sub(r"\[(.*?)\]\((.*?)\)", r'<a href="\2">\1</a>', output)
43
-
44
- # Convert lists
45
- output = re.sub(r"^\s*[\-\*] (.+)", r"• \1", output, flags=re.MULTILINE)
43
+ output = re.sub(r"!?\[(.*?)\]\((.*?)\)", r'<a href="\2">\1</a>', output)
46
44
 
47
45
  # Convert headings
48
46
  output = re.sub(r"^\s*#+ (.+)", r"<b>\1</b>", output, flags=re.MULTILINE)
49
47
 
48
+ # Convert unordered lists, preserving indentation
49
+ output = re.sub(r"^(\s*)[\-\*] (.+)", r"\1• \2", output, flags=re.MULTILINE)
50
+
50
51
  # Step 4: Reinsert the converted HTML code blocks
51
52
  output = reinsert_code_blocks(output, code_blocks)
52
53
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgpt_md_converter
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A package for converting markdown to HTML for chat Telegram bots
5
5
  Home-page: https://github.com/Latand/formatter-chatgpt-telegram
6
6
  Author: Kostiantyn Kriuchkov
@@ -0,0 +1,11 @@
1
+ chatgpt_md_converter/__init__.py,sha256=AfkikySkXsJ8HKQcSlU7B1KBHz54QCGJ7MO5Ka9oWRM,79
2
+ chatgpt_md_converter/converters.py,sha256=nfbKCcYCAYBk_0RQntCVQFQgAlEUWrGtLWULE1wETmU,657
3
+ chatgpt_md_converter/extractors.py,sha256=RNwo57_6jCe-HoX5eCvvZcjSTc2uPax-6QEtXqXA5QQ,1880
4
+ chatgpt_md_converter/formatters.py,sha256=gG_SavtZI0BVl7SqkwGZ_usCB89ZPpAQWofpDUd9DzU,878
5
+ chatgpt_md_converter/helpers.py,sha256=9CtBeMzKYrymECNPl0MXsW0Vscp4A02a64a5z0sVWqE,261
6
+ chatgpt_md_converter/telegram_formatter.py,sha256=3XSNWda_5LKRShjZlkO-D7c1Uq77pfvUGlhqliEO0eU,2007
7
+ chatgpt_md_converter-0.1.2.dist-info/LICENSE,sha256=SDr2jeP-s2g4vf17-jdLXrrqA4_mU7L_RtSJlv4Y2mk,1077
8
+ chatgpt_md_converter-0.1.2.dist-info/METADATA,sha256=roSPyHowfr_bCIlyWkja5ozrq3j8zjAQI1cI_0Iqodo,3086
9
+ chatgpt_md_converter-0.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
+ chatgpt_md_converter-0.1.2.dist-info/top_level.txt,sha256=T2o7csVtZgr-Pwm83aSUkZn0humJmDFNqW38tRSsNqw,21
11
+ chatgpt_md_converter-0.1.2.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- chatgpt_md_converter/__init__.py,sha256=AfkikySkXsJ8HKQcSlU7B1KBHz54QCGJ7MO5Ka9oWRM,79
2
- chatgpt_md_converter/converters.py,sha256=-SbsAiMetDZVkC7PrEQrrKlpoagnUycCL1WNBozd7u0,635
3
- chatgpt_md_converter/extractors.py,sha256=RNwo57_6jCe-HoX5eCvvZcjSTc2uPax-6QEtXqXA5QQ,1880
4
- chatgpt_md_converter/formatters.py,sha256=T85JwXI7t3PpqAHvkV7FFrmBar6pYRYLVLpET0TeRp0,856
5
- chatgpt_md_converter/helpers.py,sha256=9CtBeMzKYrymECNPl0MXsW0Vscp4A02a64a5z0sVWqE,261
6
- chatgpt_md_converter/telegram_formatter.py,sha256=3TrQpuVm1P4Qv1ZMrcBwD7sA2GI-yCDGuTUwUZSlw3E,1896
7
- chatgpt_md_converter-0.1.1.dist-info/LICENSE,sha256=SDr2jeP-s2g4vf17-jdLXrrqA4_mU7L_RtSJlv4Y2mk,1077
8
- chatgpt_md_converter-0.1.1.dist-info/METADATA,sha256=635E9EVpEVMP1fpbPAuDl0x_Y9cu3Ye5WfnwdjnWeYc,3086
9
- chatgpt_md_converter-0.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
- chatgpt_md_converter-0.1.1.dist-info/top_level.txt,sha256=T2o7csVtZgr-Pwm83aSUkZn0humJmDFNqW38tRSsNqw,21
11
- chatgpt_md_converter-0.1.1.dist-info/RECORD,,