chatgpt-md-converter 0.3.1__py3-none-any.whl → 0.3.3__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.
- chatgpt_md_converter-0.3.3.dist-info/METADATA +170 -0
- {chatgpt_md_converter-0.3.1.dist-info → chatgpt_md_converter-0.3.3.dist-info}/RECORD +5 -5
- chatgpt_md_converter-0.3.1.dist-info/METADATA +0 -109
- {chatgpt_md_converter-0.3.1.dist-info → chatgpt_md_converter-0.3.3.dist-info}/WHEEL +0 -0
- {chatgpt_md_converter-0.3.1.dist-info → chatgpt_md_converter-0.3.3.dist-info}/licenses/LICENSE +0 -0
- {chatgpt_md_converter-0.3.1.dist-info → chatgpt_md_converter-0.3.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chatgpt_md_converter
|
|
3
|
+
Version: 0.3.3
|
|
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
|
+
```
|
|
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.
|
|
@@ -4,8 +4,8 @@ chatgpt_md_converter/extractors.py,sha256=RNwo57_6jCe-HoX5eCvvZcjSTc2uPax-6QEtXq
|
|
|
4
4
|
chatgpt_md_converter/formatters.py,sha256=UbjRG7bLETIGDaFDbFybwW8dKYBMDmgLmIasJiw_j60,2304
|
|
5
5
|
chatgpt_md_converter/helpers.py,sha256=2Nc9_s0HcLq79mBt7Hje19LzbO6z9mUNgayoMyWkIhI,874
|
|
6
6
|
chatgpt_md_converter/telegram_formatter.py,sha256=L0ESIY1AOuRXdIto2lWR38zuYuIwlLBScGINMrm8VVk,4091
|
|
7
|
-
chatgpt_md_converter-0.3.
|
|
8
|
-
chatgpt_md_converter-0.3.
|
|
9
|
-
chatgpt_md_converter-0.3.
|
|
10
|
-
chatgpt_md_converter-0.3.
|
|
11
|
-
chatgpt_md_converter-0.3.
|
|
7
|
+
chatgpt_md_converter-0.3.3.dist-info/licenses/LICENSE,sha256=SDr2jeP-s2g4vf17-jdLXrrqA4_mU7L_RtSJlv4Y2mk,1077
|
|
8
|
+
chatgpt_md_converter-0.3.3.dist-info/METADATA,sha256=K4b1syQlvWh319Usada0rdP0ds0tYUkvKbn_r9-Z80w,5796
|
|
9
|
+
chatgpt_md_converter-0.3.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
10
|
+
chatgpt_md_converter-0.3.3.dist-info/top_level.txt,sha256=T2o7csVtZgr-Pwm83aSUkZn0humJmDFNqW38tRSsNqw,21
|
|
11
|
+
chatgpt_md_converter-0.3.3.dist-info/RECORD,,
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: chatgpt_md_converter
|
|
3
|
-
Version: 0.3.1
|
|
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
|
-
- Supports spoiler tags with `||text||` syntax.
|
|
35
|
-
- Handles nested bold and italic formatting.
|
|
36
|
-
- Converts Markdown links and lists to their HTML equivalents.
|
|
37
|
-
- Processes code blocks with optional language specification, preserving formatting within `<pre><code>` tags.
|
|
38
|
-
- Supports regular blockquotes (`>`) and expandable blockquotes (`**>`) for Telegram.
|
|
39
|
-
- Automatically appends missing closing delimiters for code blocks.
|
|
40
|
-
- Escapes HTML special characters to prevent unwanted HTML rendering outside code blocks.
|
|
41
|
-
|
|
42
|
-
## Usage
|
|
43
|
-
|
|
44
|
-
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:
|
|
45
|
-
|
|
46
|
-
1. **Ensure Closing Delimiters**: Automatically appends missing closing delimiters for `` ` `` and ` ` ``` to ensure proper parsing.
|
|
47
|
-
|
|
48
|
-
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.
|
|
49
|
-
|
|
50
|
-
3. **Markdown to HTML Conversion**: Applies various regex substitutions and custom logic to convert supported Markdown formatting to Telegram-compatible HTML tags.
|
|
51
|
-
|
|
52
|
-
4. **Reinsert Code Blocks**: Reinserts the previously extracted and converted code blocks back into the main text, replacing placeholders with the appropriate HTML content.
|
|
53
|
-
|
|
54
|
-
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.
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
You can install the package using pip:
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
pip install chatgpt-md-converter
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Example
|
|
65
|
-
|
|
66
|
-
````python
|
|
67
|
-
from chatgpt_md_converter import telegram_format
|
|
68
|
-
|
|
69
|
-
# Basic formatting
|
|
70
|
-
text = """
|
|
71
|
-
Here is some **bold**, __underline__, and `inline code`.
|
|
72
|
-
This is a ||spoiler text||.
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
print('Hello, world!')
|
|
76
|
-
````
|
|
77
|
-
|
|
78
|
-
"""
|
|
79
|
-
|
|
80
|
-
# Blockquotes
|
|
81
|
-
|
|
82
|
-
blockquote_text = """
|
|
83
|
-
|
|
84
|
-
> Regular blockquote
|
|
85
|
-
> Multiple lines
|
|
86
|
-
|
|
87
|
-
\*\*>Expandable blockquote
|
|
88
|
-
|
|
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
|
-
|
|
101
|
-
## Requirements
|
|
102
|
-
|
|
103
|
-
- Python 3.x
|
|
104
|
-
- No external libraries required (uses built-in `re` module for regex operations)
|
|
105
|
-
|
|
106
|
-
## Contribution
|
|
107
|
-
|
|
108
|
-
Feel free to contribute to this project by submitting pull requests or opening issues for bugs, feature requests, or improvements.
|
|
109
|
-
```
|
|
File without changes
|
{chatgpt_md_converter-0.3.1.dist-info → chatgpt_md_converter-0.3.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|