telegram-md2html 1.0.1 → 1.0.3
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.
- package/README.md +383 -319
- package/dist/converter.d.ts +1 -15
- package/dist/index.cjs +61 -58
- package/dist/index.esm.js +61 -58
- package/dist/index.mjs +61 -58
- package/dist/index.umd.js +61 -58
- package/dist/tokenizer.d.ts +0 -3
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,320 +1,384 @@
|
|
|
1
|
-
# Telegram Markdown to HTML Converter
|
|
2
|
-
|
|
3
|
-
A smart and efficient TypeScript/JavaScript library for converting Telegram-style Markdown to Telegram-compatible HTML. Perfect for Telegram bots, chat applications, and content processing.
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/telegram-md2html)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://nodejs.org/)
|
|
9
|
-
[](https://www.npmjs.com/package/telegram-md2html)
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Complete Telegram Markdown Support**: All Telegram-specific formatting options
|
|
14
|
-
- **Smart Parsing**: Handles nested styles and complex formatting
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# or
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
\`\`\`
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
###
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
##
|
|
273
|
-
|
|
274
|
-
The library
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
1
|
+
# Telegram Markdown to HTML Converter
|
|
2
|
+
|
|
3
|
+
A smart and efficient TypeScript/JavaScript library for converting Telegram-style Markdown to Telegram-compatible HTML. Perfect for Telegram bots, chat applications, and content processing.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/telegram-md2html)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://www.npmjs.com/package/telegram-md2html)
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Complete Telegram Markdown Support**: All Telegram-specific formatting options
|
|
14
|
+
- **Smart Parsing**: Handles nested styles and complex formatting
|
|
15
|
+
- **Username Protection**: Underscores in usernames (e.g., @username_bot) are preserved
|
|
16
|
+
- **HTML Safety**: Automatic escaping of HTML special characters
|
|
17
|
+
- **Heading Support**: Convert `##` and `###` to bold text with custom symbols
|
|
18
|
+
- **Code Block Support**: Inline code and multiline code blocks with language specification
|
|
19
|
+
- **Blockquote Support**: Regular and expandable blockquotes
|
|
20
|
+
- **Customizable**: Extensible with custom processors
|
|
21
|
+
- **TypeScript Ready**: Full TypeScript definitions included
|
|
22
|
+
- **Dual Module Support**: Works with both CommonJS and ES Modules
|
|
23
|
+
- **Browser Compatible**: Can be used in modern browsers
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install telegram-md2html
|
|
29
|
+
# or
|
|
30
|
+
yarn add telegram-md2html
|
|
31
|
+
# or
|
|
32
|
+
pnpm add telegram-md2html
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
// CommonJS
|
|
39
|
+
const { markdownToHtml } = require('telegram-md2html');
|
|
40
|
+
|
|
41
|
+
// ES Modules
|
|
42
|
+
import { markdownToHtml } from 'telegram-md2html';
|
|
43
|
+
|
|
44
|
+
// Convert Telegram markdown to HTML
|
|
45
|
+
const html = markdownToHtml('**Hello** *World*!');
|
|
46
|
+
console.log(html);
|
|
47
|
+
// Output: <b>Hello</b> <i>World</i>!
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
### Basic Conversion
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
import { markdownToHtml } from 'telegram-md2html';
|
|
56
|
+
|
|
57
|
+
const markdown = `
|
|
58
|
+
## Welcome to Telegram Bot
|
|
59
|
+
|
|
60
|
+
**Bold text** and *italic text*
|
|
61
|
+
__Underlined__ and ~~strikethrough~~
|
|
62
|
+
||Spoiler text||
|
|
63
|
+
|
|
64
|
+
`inline code`
|
|
65
|
+
|
|
66
|
+
[Visit Google](https://google.com)
|
|
67
|
+
|
|
68
|
+
> This is a quote
|
|
69
|
+
**> Expandable quote
|
|
70
|
+
|
|
71
|
+
\`\`\`javascript
|
|
72
|
+
console.log("Hello World");
|
|
73
|
+
\`\`\`
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
const html = markdownToHtml(markdown);
|
|
77
|
+
console.log(html);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Headings with Custom Symbol
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
import { createConverter } from 'telegram-md2html';
|
|
84
|
+
|
|
85
|
+
// Custom symbol for headings
|
|
86
|
+
const converter = createConverter({
|
|
87
|
+
headingSymbol: '📌' // or '▎' (default), '⚡', '🔹', etc.
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const html = converter.convert('## Important Title');
|
|
91
|
+
// Output: <b>📌 Important Title</b>
|
|
92
|
+
|
|
93
|
+
// No symbol (just bold)
|
|
94
|
+
const blankConverter = createConverter({ headingBlank: true });
|
|
95
|
+
const result = blankConverter.convert('### Subtitle');
|
|
96
|
+
// Output: <b>Subtitle</b>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Username Protection
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
import { markdownToHtml } from 'telegram-md2html';
|
|
103
|
+
|
|
104
|
+
// Underscores in usernames are NOT converted to italic
|
|
105
|
+
const html = markdownToHtml('Hello @my_telegram_bot');
|
|
106
|
+
// Output: Hello @my_telegram_bot (preserved, no italic formatting)
|
|
107
|
+
|
|
108
|
+
// Real italic still works
|
|
109
|
+
const html2 = markdownToHtml('This is *italic* text');
|
|
110
|
+
// Output: This is <i>italic</i> text
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Advanced Usage with Options
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
import { createConverter } from 'telegram-md2html';
|
|
117
|
+
|
|
118
|
+
// Create a converter with custom options
|
|
119
|
+
const converter = createConverter({
|
|
120
|
+
escapeHtml: true,
|
|
121
|
+
autoCloseCodeBlocks: true,
|
|
122
|
+
headingSymbol: '🔹',
|
|
123
|
+
linkProcessor: (url, text) =>
|
|
124
|
+
`<a href="\${url}" target="_blank" rel="noopener">\${text}</a>`,
|
|
125
|
+
codeBlockProcessor: (code, language) =>
|
|
126
|
+
`<pre><code class="language-\${language || 'text'}">\${code}</code></pre>`
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const html = converter.convert('**[Important Link](https://example.com)**');
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Supported Markdown Syntax
|
|
133
|
+
|
|
134
|
+
| Markdown | HTML Output | Description |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| `## text` | `<b>▎ text</b>` | Level 2 heading |
|
|
137
|
+
| `### text` | `<b>▎ text</b>` | Level 3 heading |
|
|
138
|
+
| `**text**` | `<b>text</b>` | Bold text |
|
|
139
|
+
| `*text*` or `_text_` | `<i>text</i>` | Italic text |
|
|
140
|
+
| `__text__` | `<u>text</u>` | Underlined text |
|
|
141
|
+
| `~~text~~` | `<s>text</s>` | Strikethrough text |
|
|
142
|
+
| `\|\|text\|\|` | `<span class="tg-spoiler">text</span>` | Spoiler text |
|
|
143
|
+
| `` `code` `` | `<code>code</code>` | Inline code |
|
|
144
|
+
| \`\`\`language\ncode\n\`\`\` | `<pre><code class="language-xxx">code</code></pre>` | Code block |
|
|
145
|
+
| `[text](url)` | `<a href="url">text</a>` | Hyperlink |
|
|
146
|
+
| `> text` | `<blockquote>text</blockquote>` | Blockquote |
|
|
147
|
+
| `**> text**` | `<blockquote expandable>text</blockquote>` | Expandable blockquote |
|
|
148
|
+
| `- text` | `<ul><li>text</li></ul>` | Unordered list |
|
|
149
|
+
| `1. text` | `<ol><li>text</li></ol>` | Ordered list |
|
|
150
|
+
| `---` | `<hr>` | Horizontal rule |
|
|
151
|
+
| `` | `<img src="url" alt="alt">` | Image |
|
|
152
|
+
|
|
153
|
+
## API Reference
|
|
154
|
+
|
|
155
|
+
### `markdownToHtml(text: string, options?: ConvertOptions): string`
|
|
156
|
+
|
|
157
|
+
Main conversion function that converts Telegram-style markdown to HTML.
|
|
158
|
+
|
|
159
|
+
**Parameters:**
|
|
160
|
+
- `text`: The markdown text to convert
|
|
161
|
+
- `options`: Optional conversion options
|
|
162
|
+
|
|
163
|
+
**Returns:** Telegram-compatible HTML string
|
|
164
|
+
|
|
165
|
+
### `createConverter(options?: ConvertOptions): MarkdownConverter`
|
|
166
|
+
|
|
167
|
+
Creates a converter instance with custom options for reuse.
|
|
168
|
+
|
|
169
|
+
### ConvertOptions Interface
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
interface ConvertOptions {
|
|
173
|
+
/** Whether to escape HTML special characters (default: true) */
|
|
174
|
+
escapeHtml?: boolean;
|
|
175
|
+
|
|
176
|
+
/** Whether to auto-close unclosed code blocks (default: true) */
|
|
177
|
+
autoCloseCodeBlocks?: boolean;
|
|
178
|
+
|
|
179
|
+
/** Custom symbol for headings (default: '▎') */
|
|
180
|
+
headingSymbol?: string;
|
|
181
|
+
|
|
182
|
+
/** Whether to show blank (no symbol) for headings (default: false) */
|
|
183
|
+
headingBlank?: boolean;
|
|
184
|
+
|
|
185
|
+
/** Custom link processor function */
|
|
186
|
+
linkProcessor?: (url: string, text: string) => string;
|
|
187
|
+
|
|
188
|
+
/** Custom code block processor function */
|
|
189
|
+
codeBlockProcessor?: (code: string, language?: string) => string;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## TypeScript Support
|
|
194
|
+
|
|
195
|
+
The library includes full TypeScript definitions. Just import and use:
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import { markdownToHtml, ConvertOptions } from 'telegram-md2html';
|
|
199
|
+
|
|
200
|
+
const options: ConvertOptions = {
|
|
201
|
+
escapeHtml: false,
|
|
202
|
+
headingSymbol: '⚡',
|
|
203
|
+
linkProcessor: (url: string, text: string): string => {
|
|
204
|
+
return `<a href="\${url}" class="custom-link">\${text}</a>`;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const html: string = markdownToHtml('## TypeScript works!', options);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Browser Usage
|
|
212
|
+
|
|
213
|
+
The library can be used in modern browsers:
|
|
214
|
+
|
|
215
|
+
### Using ES Modules (Recommended)
|
|
216
|
+
|
|
217
|
+
```html
|
|
218
|
+
<script type="module">
|
|
219
|
+
import { markdownToHtml } from 'https://cdn.jsdelivr.net/npm/telegram-md2html/dist/index.mjs';
|
|
220
|
+
|
|
221
|
+
const html = markdownToHtml('**Hello** from browser!');
|
|
222
|
+
document.getElementById('output').innerHTML = html;
|
|
223
|
+
</script>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Using from GitHub
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<script type="module">
|
|
230
|
+
import { markdownToHtml } from 'https://cdn.jsdelivr.net/gh/Soumyadeep765/telegram-md2html@main/dist/index.mjs';
|
|
231
|
+
|
|
232
|
+
const html = markdownToHtml('**Hello** World');
|
|
233
|
+
document.getElementById('output').innerHTML = html;
|
|
234
|
+
</script>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Using a CDN
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<script src="https://cdn.jsdelivr.net/npm/telegram-md2html/dist/index.js"></script>
|
|
241
|
+
<script>
|
|
242
|
+
// Available as window.telegramMd2Html
|
|
243
|
+
const html = telegramMd2Html.markdownToHtml('**CDN** Example');
|
|
244
|
+
document.getElementById('output').innerHTML = html;
|
|
245
|
+
</script>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Complex Nested Example
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
const result = markdownToHtml(`
|
|
252
|
+
## Welcome to our bot!
|
|
253
|
+
|
|
254
|
+
Features:
|
|
255
|
+
• *Easy formatting*
|
|
256
|
+
• __Multiple styles__
|
|
257
|
+
• ~~Clean output~~
|
|
258
|
+
• Username @test_bot works fine
|
|
259
|
+
|
|
260
|
+
\`\`\`python
|
|
261
|
+
def greet():
|
|
262
|
+
print("Hello from Python!")
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
> Remember: **Formatting** makes messages _better_
|
|
266
|
+
**> Click to expand details
|
|
267
|
+
`);
|
|
268
|
+
|
|
269
|
+
console.log(result);
|
|
270
|
+
\`\`\`
|
|
271
|
+
|
|
272
|
+
## Error Handling
|
|
273
|
+
|
|
274
|
+
The library handles edge cases gracefully:
|
|
275
|
+
|
|
276
|
+
- Unclosed code blocks are automatically closed
|
|
277
|
+
- HTML characters are properly escaped by default
|
|
278
|
+
- Invalid markdown is treated as plain text
|
|
279
|
+
- Nested styles are processed correctly
|
|
280
|
+
- Usernames with underscores are not treated as italic
|
|
281
|
+
|
|
282
|
+
## Performance
|
|
283
|
+
|
|
284
|
+
The library is optimized for performance:
|
|
285
|
+
- Efficient tokenization algorithm
|
|
286
|
+
- Minimal memory usage
|
|
287
|
+
- No external dependencies
|
|
288
|
+
- Fast parsing even for large documents
|
|
289
|
+
|
|
290
|
+
## Contributing
|
|
291
|
+
|
|
292
|
+
Contributions are welcome! Here's how you can help:
|
|
293
|
+
|
|
294
|
+
1. Fork the repository
|
|
295
|
+
2. Create a feature branch: `git checkout -b feature-name`
|
|
296
|
+
3. Make your changes
|
|
297
|
+
4. Add tests for new functionality
|
|
298
|
+
5. Run tests: `npm test`
|
|
299
|
+
6. Commit your changes: `git commit -am 'Add feature'`
|
|
300
|
+
7. Push to the branch: `git push origin feature-name`
|
|
301
|
+
8. Submit a pull request
|
|
302
|
+
|
|
303
|
+
### Development Setup
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Clone the repository
|
|
307
|
+
git clone https://github.com/Soumyadeep765/telegram-md2html.git
|
|
308
|
+
cd telegram-md2html
|
|
309
|
+
|
|
310
|
+
# Install dependencies
|
|
311
|
+
npm install
|
|
312
|
+
|
|
313
|
+
# Build the library
|
|
314
|
+
npm run build
|
|
315
|
+
|
|
316
|
+
# Run tests
|
|
317
|
+
npm test
|
|
318
|
+
|
|
319
|
+
# Watch mode for development
|
|
320
|
+
npm run dev
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Testing
|
|
324
|
+
|
|
325
|
+
The library includes comprehensive tests:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# Run all tests
|
|
329
|
+
npm test
|
|
330
|
+
|
|
331
|
+
# Run tests with coverage
|
|
332
|
+
npm test -- --coverage
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## License
|
|
336
|
+
|
|
337
|
+
This project is licensed under the **MIT** License
|
|
338
|
+
|
|
339
|
+
## Support
|
|
340
|
+
|
|
341
|
+
If you find this library useful, please consider:
|
|
342
|
+
|
|
343
|
+
- Starring the repository on GitHub
|
|
344
|
+
- Sharing it with others
|
|
345
|
+
- Reporting issues
|
|
346
|
+
- Suggesting new features
|
|
347
|
+
|
|
348
|
+
## Changelog
|
|
349
|
+
|
|
350
|
+
### v1.0.3 (Current)
|
|
351
|
+
- **Fixed**: Username underscore bug - `@username_bot` no longer triggers italic formatting
|
|
352
|
+
- **Added**: Heading support for `##` and `###` with configurable symbol (default: '▎')
|
|
353
|
+
- **Added**: `headingSymbol` and `headingBlank` options for heading customization
|
|
354
|
+
- **Improved**: Italic detection with word boundary checks
|
|
355
|
+
- **Fixed**: Preserved underscores in usernames, file names, and code blocks
|
|
356
|
+
- **Improved**: Better handling of mixed formatting with usernames
|
|
357
|
+
|
|
358
|
+
### v1.0.2
|
|
359
|
+
- **Improved output formatting**: Removed extra newlines around code blocks and quotes
|
|
360
|
+
- Cleaner HTML output without unnecessary whitespace
|
|
361
|
+
- Better preservation of original markdown formatting
|
|
362
|
+
|
|
363
|
+
### v1.0.1
|
|
364
|
+
- Initial release
|
|
365
|
+
- Complete Telegram markdown support
|
|
366
|
+
- TypeScript definitions
|
|
367
|
+
- Browser compatibility
|
|
368
|
+
- Custom processor support
|
|
369
|
+
|
|
370
|
+
## Author
|
|
371
|
+
|
|
372
|
+
**Soumyadeep Das**
|
|
373
|
+
- GitHub: [@Soumyadeep765](https://github.com/Soumyadeep765/telegram-md2html)
|
|
374
|
+
- Email: soumyadeepdas765@gmail.com
|
|
375
|
+
|
|
376
|
+
## Acknowledgments
|
|
377
|
+
|
|
378
|
+
- Telegram for their excellent Bot API
|
|
379
|
+
- All contributors and users of this library
|
|
380
|
+
- The open source community for inspiration and support
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
320
384
|
**Note**: This library is not affiliated with or endorsed by Telegram.
|