chatgpt-md-converter 0.3.0__tar.gz → 0.3.2__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.
Files changed (17) hide show
  1. chatgpt_md_converter-0.3.2/PKG-INFO +170 -0
  2. chatgpt_md_converter-0.3.2/chatgpt_md_converter.egg-info/PKG-INFO +170 -0
  3. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/setup.py +1 -1
  4. chatgpt_md_converter-0.3.0/PKG-INFO +0 -78
  5. chatgpt_md_converter-0.3.0/chatgpt_md_converter.egg-info/PKG-INFO +0 -78
  6. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/LICENSE +0 -0
  7. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/__init__.py +0 -0
  8. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/converters.py +0 -0
  9. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/extractors.py +0 -0
  10. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/formatters.py +0 -0
  11. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/helpers.py +0 -0
  12. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter/telegram_formatter.py +0 -0
  13. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter.egg-info/SOURCES.txt +0 -0
  14. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter.egg-info/dependency_links.txt +0 -0
  15. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/chatgpt_md_converter.egg-info/top_level.txt +0 -0
  16. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/setup.cfg +0 -0
  17. {chatgpt_md_converter-0.3.0 → chatgpt_md_converter-0.3.2}/tests/test_parser.py +0 -0
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: chatgpt_md_converter
3
+ Version: 0.3.2
4
+ Summary: A package for converting markdown to HTML for chat Telegram bots
5
+ Home-page: https://github.com/Latand/formatter-chatgpt-telegram
6
+ Author: Kostiantyn Kriuchkov
7
+ Author-email: latand666@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license-file
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ # ChatGPT Markdown to Telegram HTML Parser
25
+
26
+ ## Overview
27
+
28
+ This project provides a solution for converting Telegram-style Markdown formatted text into HTML markup supported by the Telegram Bot API, specifically tailored for use in ChatGPT bots developed with the OpenAI API. It includes features for handling various Markdown elements and ensures proper tag closure, making it suitable for streaming mode applications.
29
+
30
+ ## Features
31
+
32
+ - Converts Telegram-style Markdown syntax to Telegram-compatible HTML
33
+ - Supports text styling:
34
+ - Bold: `**text**` → `<b>text</b>`
35
+ - Italic: `*text*` or `_text_` → `<i>text</i>`
36
+ - Underline: `__text__` → `<u>text</u>`
37
+ - Strikethrough: `~~text~~` → `<s>text</s>`
38
+ - Spoiler: `||text||` → `<span class="tg-spoiler">text</span>`
39
+ - Inline code: `` `code` `` → `<code>code</code>`
40
+ - Handles nested text styling
41
+ - Converts links: `[text](URL)` → `<a href="URL">text</a>`
42
+ - Processes code blocks with language specification
43
+ - Supports blockquotes:
44
+ - Regular blockquotes: `> text` → `<blockquote>text</blockquote>`
45
+ - Expandable blockquotes: `**> text` → `<blockquote expandable>text</blockquote>`
46
+ - Automatically appends missing closing delimiters for code blocks
47
+ - Escapes HTML special characters to prevent unwanted HTML rendering
48
+
49
+ ## Usage
50
+
51
+ To use the Markdown to Telegram HTML Parser in your ChatGPT bot, integrate the provided Python functions into your bot's processing pipeline. Here is a brief overview of how to incorporate the parser:
52
+
53
+ 1. **Ensure Closing Delimiters**: Automatically appends missing closing delimiters for backticks to ensure proper parsing.
54
+
55
+ 2. **Extract and Convert Code Blocks**: Extracts Markdown code blocks, converts them to HTML `<pre><code>` format, and replaces them with placeholders to prevent formatting within code blocks.
56
+
57
+ 3. **Markdown to HTML Conversion**: Applies various regex substitutions and custom logic to convert supported Markdown formatting to Telegram-compatible HTML tags.
58
+
59
+ 4. **Reinsert Code Blocks**: Reinserts the previously extracted and converted code blocks back into the main text, replacing placeholders with the appropriate HTML content.
60
+
61
+ Simply call the `telegram_format(text: str) -> str` function with your Markdown-formatted text as input to receive the converted HTML output ready for use with the Telegram Bot API.
62
+
63
+ ## Installation
64
+
65
+ ```sh
66
+ pip install chatgpt-md-converter
67
+ ```
68
+
69
+ ## Example
70
+
71
+ ```python
72
+ from chatgpt_md_converter import telegram_format
73
+
74
+ # Basic formatting example
75
+ text = """
76
+ Here is some **bold**, __underline__, and `inline code`.
77
+ This is a ||spoiler text|| and *italic*.
78
+
79
+ Code example:
80
+ print('Hello, world!')
81
+ """
82
+
83
+ # Blockquotes example
84
+ blockquote_text = """
85
+ > Regular blockquote
86
+ > Multiple lines
87
+
88
+ **> Expandable blockquote
89
+ > Hidden by default
90
+ > Multiple lines
91
+ """
92
+
93
+ formatted_text = telegram_format(text)
94
+ formatted_blockquote = telegram_format(blockquote_text)
95
+
96
+ print(formatted_text)
97
+ print(formatted_blockquote)
98
+ ```
99
+
100
+ ### Output:
101
+
102
+ ```
103
+ Here is some <b>bold</b>, <u>underline</u>, and <code>inline code</code>.
104
+ This is a <span class="tg-spoiler">spoiler text</span> and <i>italic</i>.
105
+
106
+ Code example:
107
+ print('Hello, world!')
108
+
109
+ <blockquote>Regular blockquote
110
+ Multiple lines</blockquote>
111
+
112
+ <blockquote expandable>Expandable blockquote
113
+ Hidden by default
114
+ Multiple lines</blockquote>
115
+ ```
116
+
117
+ ## Requirements
118
+
119
+ - Python 3.x
120
+ - No external libraries required (uses built-in `re` module for regex operations)
121
+
122
+ ## Contribution
123
+
124
+ Feel free to contribute to this project by submitting pull requests or opening issues for bugs, feature requests, or improvements.
125
+
126
+ ## Prompting LLMs for Telegram-Specific Formatting
127
+
128
+ > **Note**:
129
+ > Since standard Markdown doesn't include Telegram-specific features like spoilers (`||text||`) and expandable blockquotes (`**> text`), you'll need to explicitly instruct LLMs to use these formats. Here's a suggested prompt addition to include in your system message or initial instructions:
130
+
131
+ ````md
132
+ When formatting your responses for Telegram, please use these special formatting conventions:
133
+
134
+ 1. For content that should be hidden as a spoiler (revealed only when users click):
135
+ Use: ||spoiler content here||
136
+ Example: This is visible, but ||this is hidden until clicked||.
137
+
138
+ 2. For lengthy explanations or optional content that should be collapsed:
139
+ Use: \*\*> Expandable section title
140
+
141
+ > Content line 1
142
+ > Content line 2
143
+ > (Each line of the expandable blockquote should start with ">")
144
+
145
+ 3. Continue using standard markdown for other formatting:
146
+ - **bold text**
147
+ - _italic text_ or _italic text_
148
+ - **underlined text**
149
+ - ~~strikethrough~~
150
+ - `inline code`
151
+ - `code blocks`
152
+ - [link text](URL)
153
+
154
+ Apply spoilers for:
155
+
156
+ - Solution reveals
157
+ - Potential plot spoilers
158
+ - Sensitive information
159
+ - Surprising facts
160
+
161
+ Use expandable blockquotes for:
162
+
163
+ - Detailed explanations
164
+ - Long examples
165
+ - Optional reading
166
+ - Technical details
167
+ - Additional context not needed by all users
168
+ ````
169
+
170
+ You can add this prompt to your system message when initializing your ChatGPT interactions to ensure the model properly formats content for optimal display in Telegram.
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: chatgpt_md_converter
3
+ Version: 0.3.2
4
+ Summary: A package for converting markdown to HTML for chat Telegram bots
5
+ Home-page: https://github.com/Latand/formatter-chatgpt-telegram
6
+ Author: Kostiantyn Kriuchkov
7
+ Author-email: latand666@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license-file
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ # ChatGPT Markdown to Telegram HTML Parser
25
+
26
+ ## Overview
27
+
28
+ This project provides a solution for converting Telegram-style Markdown formatted text into HTML markup supported by the Telegram Bot API, specifically tailored for use in ChatGPT bots developed with the OpenAI API. It includes features for handling various Markdown elements and ensures proper tag closure, making it suitable for streaming mode applications.
29
+
30
+ ## Features
31
+
32
+ - Converts Telegram-style Markdown syntax to Telegram-compatible HTML
33
+ - Supports text styling:
34
+ - Bold: `**text**` → `<b>text</b>`
35
+ - Italic: `*text*` or `_text_` → `<i>text</i>`
36
+ - Underline: `__text__` → `<u>text</u>`
37
+ - Strikethrough: `~~text~~` → `<s>text</s>`
38
+ - Spoiler: `||text||` → `<span class="tg-spoiler">text</span>`
39
+ - Inline code: `` `code` `` → `<code>code</code>`
40
+ - Handles nested text styling
41
+ - Converts links: `[text](URL)` → `<a href="URL">text</a>`
42
+ - Processes code blocks with language specification
43
+ - Supports blockquotes:
44
+ - Regular blockquotes: `> text` → `<blockquote>text</blockquote>`
45
+ - Expandable blockquotes: `**> text` → `<blockquote expandable>text</blockquote>`
46
+ - Automatically appends missing closing delimiters for code blocks
47
+ - Escapes HTML special characters to prevent unwanted HTML rendering
48
+
49
+ ## Usage
50
+
51
+ To use the Markdown to Telegram HTML Parser in your ChatGPT bot, integrate the provided Python functions into your bot's processing pipeline. Here is a brief overview of how to incorporate the parser:
52
+
53
+ 1. **Ensure Closing Delimiters**: Automatically appends missing closing delimiters for backticks to ensure proper parsing.
54
+
55
+ 2. **Extract and Convert Code Blocks**: Extracts Markdown code blocks, converts them to HTML `<pre><code>` format, and replaces them with placeholders to prevent formatting within code blocks.
56
+
57
+ 3. **Markdown to HTML Conversion**: Applies various regex substitutions and custom logic to convert supported Markdown formatting to Telegram-compatible HTML tags.
58
+
59
+ 4. **Reinsert Code Blocks**: Reinserts the previously extracted and converted code blocks back into the main text, replacing placeholders with the appropriate HTML content.
60
+
61
+ Simply call the `telegram_format(text: str) -> str` function with your Markdown-formatted text as input to receive the converted HTML output ready for use with the Telegram Bot API.
62
+
63
+ ## Installation
64
+
65
+ ```sh
66
+ pip install chatgpt-md-converter
67
+ ```
68
+
69
+ ## Example
70
+
71
+ ```python
72
+ from chatgpt_md_converter import telegram_format
73
+
74
+ # Basic formatting example
75
+ text = """
76
+ Here is some **bold**, __underline__, and `inline code`.
77
+ This is a ||spoiler text|| and *italic*.
78
+
79
+ Code example:
80
+ print('Hello, world!')
81
+ """
82
+
83
+ # Blockquotes example
84
+ blockquote_text = """
85
+ > Regular blockquote
86
+ > Multiple lines
87
+
88
+ **> Expandable blockquote
89
+ > Hidden by default
90
+ > Multiple lines
91
+ """
92
+
93
+ formatted_text = telegram_format(text)
94
+ formatted_blockquote = telegram_format(blockquote_text)
95
+
96
+ print(formatted_text)
97
+ print(formatted_blockquote)
98
+ ```
99
+
100
+ ### Output:
101
+
102
+ ```
103
+ Here is some <b>bold</b>, <u>underline</u>, and <code>inline code</code>.
104
+ This is a <span class="tg-spoiler">spoiler text</span> and <i>italic</i>.
105
+
106
+ Code example:
107
+ print('Hello, world!')
108
+
109
+ <blockquote>Regular blockquote
110
+ Multiple lines</blockquote>
111
+
112
+ <blockquote expandable>Expandable blockquote
113
+ Hidden by default
114
+ Multiple lines</blockquote>
115
+ ```
116
+
117
+ ## Requirements
118
+
119
+ - Python 3.x
120
+ - No external libraries required (uses built-in `re` module for regex operations)
121
+
122
+ ## Contribution
123
+
124
+ Feel free to contribute to this project by submitting pull requests or opening issues for bugs, feature requests, or improvements.
125
+
126
+ ## Prompting LLMs for Telegram-Specific Formatting
127
+
128
+ > **Note**:
129
+ > Since standard Markdown doesn't include Telegram-specific features like spoilers (`||text||`) and expandable blockquotes (`**> text`), you'll need to explicitly instruct LLMs to use these formats. Here's a suggested prompt addition to include in your system message or initial instructions:
130
+
131
+ ````md
132
+ When formatting your responses for Telegram, please use these special formatting conventions:
133
+
134
+ 1. For content that should be hidden as a spoiler (revealed only when users click):
135
+ Use: ||spoiler content here||
136
+ Example: This is visible, but ||this is hidden until clicked||.
137
+
138
+ 2. For lengthy explanations or optional content that should be collapsed:
139
+ Use: \*\*> Expandable section title
140
+
141
+ > Content line 1
142
+ > Content line 2
143
+ > (Each line of the expandable blockquote should start with ">")
144
+
145
+ 3. Continue using standard markdown for other formatting:
146
+ - **bold text**
147
+ - _italic text_ or _italic text_
148
+ - **underlined text**
149
+ - ~~strikethrough~~
150
+ - `inline code`
151
+ - `code blocks`
152
+ - [link text](URL)
153
+
154
+ Apply spoilers for:
155
+
156
+ - Solution reveals
157
+ - Potential plot spoilers
158
+ - Sensitive information
159
+ - Surprising facts
160
+
161
+ Use expandable blockquotes for:
162
+
163
+ - Detailed explanations
164
+ - Long examples
165
+ - Optional reading
166
+ - Technical details
167
+ - Additional context not needed by all users
168
+ ````
169
+
170
+ You can add this prompt to your system message when initializing your ChatGPT interactions to ensure the model properly formats content for optimal display in Telegram.
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name="chatgpt_md_converter",
5
- version="0.3.0",
5
+ version="0.3.2",
6
6
  author="Kostiantyn Kriuchkov",
7
7
  author_email="latand666@gmail.com",
8
8
  description="A package for converting markdown to HTML for chat Telegram bots",
@@ -1,78 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: chatgpt_md_converter
3
- Version: 0.3.0
4
- Summary: A package for converting markdown to HTML for chat Telegram bots
5
- Home-page: https://github.com/Latand/formatter-chatgpt-telegram
6
- Author: Kostiantyn Kriuchkov
7
- Author-email: latand666@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Dynamic: author
15
- Dynamic: author-email
16
- Dynamic: classifier
17
- Dynamic: description
18
- Dynamic: description-content-type
19
- Dynamic: home-page
20
- Dynamic: license-file
21
- Dynamic: requires-python
22
- Dynamic: summary
23
-
24
- # ChatGPT Markdown to Telegram HTML Parser
25
-
26
- ## Overview
27
-
28
- This project provides a solution for converting Markdown formatted text into HTML markup supported by the Telegram Bot API, specifically tailored for use in ChatGPT bots developed with the OpenAI API. It includes features for handling various Markdown elements and ensures proper tag closure, making it suitable for streaming mode applications.
29
-
30
- ## Features
31
-
32
- - Converts Markdown syntax to Telegram-compatible HTML.
33
- - Supports inline code, bold, italic, underline, and strikethrough formatting.
34
- - Handles nested bold and italic formatting.
35
- - Converts Markdown links and lists to their HTML equivalents.
36
- - Processes code blocks with optional language specification, preserving formatting within `<pre><code>` tags.
37
- - Automatically appends missing closing delimiters for code blocks.
38
- - Escapes HTML special characters to prevent unwanted HTML rendering outside code blocks.
39
-
40
- ## Usage
41
-
42
- To use the Markdown to Telegram HTML Parser in your ChatGPT bot, integrate the provided Python functions into your bot's processing pipeline. Here is a brief overview of how to incorporate the parser:
43
-
44
- 1. **Ensure Closing Delimiters**: Automatically appends missing closing delimiters for `` ` `` and ``` ``` ``` to ensure proper parsing.
45
-
46
- 2. **Extract and Convert Code Blocks**: Extracts Markdown code blocks, converts them to HTML `<pre><code>` format, and replaces them with placeholders to prevent formatting within code blocks.
47
-
48
- 3. **Markdown to HTML Conversion**: Applies various regex substitutions and custom logic to convert supported Markdown formatting to Telegram-compatible HTML tags.
49
-
50
- 4. **Reinsert Code Blocks**: Reinserts the previously extracted and converted code blocks back into the main text, replacing placeholders with the appropriate HTML content.
51
-
52
- Simply call the `telegram_format(text: str) -> str` function with your Markdown-formatted text as input to receive the converted HTML output ready for use with the Telegram Bot API.
53
-
54
- ## Installation
55
-
56
- You can install the package using pip:
57
-
58
- ```sh
59
- pip install chatgpt-md-converter
60
- ```
61
-
62
- ## Example
63
-
64
- ```python
65
- from chatgpt_md_converter import telegram_format
66
-
67
- formatted_text = telegram_format("Here is some **bold**, __underline__, and `inline code`.\n```python\nprint('Hello, world!')\n```")
68
- print(formatted_text)
69
- ```
70
-
71
- ## Requirements
72
-
73
- - Python 3.x
74
- - No external libraries required (uses built-in `re` module for regex operations)
75
-
76
- ## Contribution
77
-
78
- Feel free to contribute to this project by submitting pull requests or opening issues for bugs, feature requests, or improvements.
@@ -1,78 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: chatgpt_md_converter
3
- Version: 0.3.0
4
- Summary: A package for converting markdown to HTML for chat Telegram bots
5
- Home-page: https://github.com/Latand/formatter-chatgpt-telegram
6
- Author: Kostiantyn Kriuchkov
7
- Author-email: latand666@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Dynamic: author
15
- Dynamic: author-email
16
- Dynamic: classifier
17
- Dynamic: description
18
- Dynamic: description-content-type
19
- Dynamic: home-page
20
- Dynamic: license-file
21
- Dynamic: requires-python
22
- Dynamic: summary
23
-
24
- # ChatGPT Markdown to Telegram HTML Parser
25
-
26
- ## Overview
27
-
28
- This project provides a solution for converting Markdown formatted text into HTML markup supported by the Telegram Bot API, specifically tailored for use in ChatGPT bots developed with the OpenAI API. It includes features for handling various Markdown elements and ensures proper tag closure, making it suitable for streaming mode applications.
29
-
30
- ## Features
31
-
32
- - Converts Markdown syntax to Telegram-compatible HTML.
33
- - Supports inline code, bold, italic, underline, and strikethrough formatting.
34
- - Handles nested bold and italic formatting.
35
- - Converts Markdown links and lists to their HTML equivalents.
36
- - Processes code blocks with optional language specification, preserving formatting within `<pre><code>` tags.
37
- - Automatically appends missing closing delimiters for code blocks.
38
- - Escapes HTML special characters to prevent unwanted HTML rendering outside code blocks.
39
-
40
- ## Usage
41
-
42
- To use the Markdown to Telegram HTML Parser in your ChatGPT bot, integrate the provided Python functions into your bot's processing pipeline. Here is a brief overview of how to incorporate the parser:
43
-
44
- 1. **Ensure Closing Delimiters**: Automatically appends missing closing delimiters for `` ` `` and ``` ``` ``` to ensure proper parsing.
45
-
46
- 2. **Extract and Convert Code Blocks**: Extracts Markdown code blocks, converts them to HTML `<pre><code>` format, and replaces them with placeholders to prevent formatting within code blocks.
47
-
48
- 3. **Markdown to HTML Conversion**: Applies various regex substitutions and custom logic to convert supported Markdown formatting to Telegram-compatible HTML tags.
49
-
50
- 4. **Reinsert Code Blocks**: Reinserts the previously extracted and converted code blocks back into the main text, replacing placeholders with the appropriate HTML content.
51
-
52
- Simply call the `telegram_format(text: str) -> str` function with your Markdown-formatted text as input to receive the converted HTML output ready for use with the Telegram Bot API.
53
-
54
- ## Installation
55
-
56
- You can install the package using pip:
57
-
58
- ```sh
59
- pip install chatgpt-md-converter
60
- ```
61
-
62
- ## Example
63
-
64
- ```python
65
- from chatgpt_md_converter import telegram_format
66
-
67
- formatted_text = telegram_format("Here is some **bold**, __underline__, and `inline code`.\n```python\nprint('Hello, world!')\n```")
68
- print(formatted_text)
69
- ```
70
-
71
- ## Requirements
72
-
73
- - Python 3.x
74
- - No external libraries required (uses built-in `re` module for regex operations)
75
-
76
- ## Contribution
77
-
78
- Feel free to contribute to this project by submitting pull requests or opening issues for bugs, feature requests, or improvements.