Socket
Book a DemoInstallSign in
Socket

formatter-chatgpt-telegram

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formatter-chatgpt-telegram

A package for converting markdown to HTML for chat Telegram bots

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

Ci Status Npm version

ChatGPT Markdown to Telegram HTML Converter - TypeScript

This library is convertation to Typescript of Python version formatter-chatgpt-telegram originally crafted by @Latand

A TypeScript library for converting Markdown to HTML format supported by the Telegram Bot API.

Installation

npm install formatter-chatgpt-telegram

Usage

import telegramFormat from 'formatter-chatgpt-telegram';

// Your Markdown text
const markdown = `
# Heading

This is _italic_ and **bold** text.

\`\`\`python
def hello():
    print("Hello, world!")
\`\`\`

- First list item
- Second list item
`;

// Convert to HTML compatible with Telegram
const html = telegramFormat(markdown);
console.log(html);

Supported Syntax

Code Blocks

Multiline Code Blocks with Language Specification

```python
def hello_world():
    print("Hello, World!")
```

Will be converted to:

<pre><code class="language-python">def hello_world():
    print("Hello, World!")</code></pre>

Inline Code Blocks

Here is inline `code`.

Will be converted to:

Here is inline <code>code</code>.

Text Styling

MarkdownHTMLResult in Telegram
**bold text**<b>bold text</b>bold text
__underlined__<u>underlined</u>underlined
*italic* or _italic_<i>italic</i>italic
***bold and italic***<b><i>bold and italic</i></b>bold and italic
___underline italic___<u><i>underline italic</i></u>underline italic
~~strikethrough~~<s>strikethrough</s>strikethrough
||spoiler||<span class="tg-spoiler">spoiler</span>spoiler

Headers

Headers are converted to bold text:

# Header 1

## Header 2

### Header 3

Will be converted to:

<b>Header 1</b>
<b>Header 2</b>
<b>Header 3</b>

Lists

Unordered lists using * or -:

- First item
- Second item

Will be converted to:

• First item
• Second item

Links are converted to HTML <a> tags:

[Link text](https://example.com)

Will be converted to:

<a href="https://example.com">Link text</a>

Blockquotes

> This is a quote
> spanning multiple lines

Will be converted to:

<blockquote>This is a quote spanning multiple lines</blockquote>

Expandable Blockquotes

**> This is an expandable quote
**> spanning multiple lines

Will be converted to:

<blockquote expandable>This is an expandable quote spanning multiple lines</blockquote>

Development

npm run format # code fomatting
npm run test # testing

Active maintenance with care and ❤️.

Feel free to send a PR.

License

MIT

Keywords

markdown

FAQs

Package last updated on 01 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.