New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@flla/telegram-format

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

@flla/telegram-format

Format Telegram message texts with Markdown or HTML

latest
Source
npmnpm
Version
3.1.2
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

telegram-format

NPM Version node JSR Version JSR Score

Format Telegram message texts with Markdown or HTML

This library abstracts the formatting options for you.

Install

Node.js:

npm install @flla/telegram-format

Deno:

deno add @edjopato/telegram-format

Usage

import { html as format } from "telegram-format";
import { markdownv2 as format } from "telegram-format";

format.bold("hey");
//=> "*hey*"

format.italic("you");
//=> "_you_"

format.bold(format.italic("they"));
//=> "*_they_*"

format.url("me", "https://edjopato.de");
//=> "[me](https://edjopato.de)"

// Legacy but still works
import { markdown as format } from "telegram-format";

When using format as an alias its easy to switch between Markdown and HTML fast.

Escaping Input

When you have something that might be unescaped you need to use format.escape before formatting it.

const username = "master_yoda";
format.italic(format.escape(username));

format.monospace and format.monospaceBlock will escape on their own as they only need to escape specific characters. You do not need to escape the input in these cases.

MarkdownV2 and HTML are fairly similar in escaping inputs but Markdown is not. Markdown is still supported by this library and by Telegram for legacy reasons, but it behaves a bit differently. Markdown still escapes inputs and does not need format.escape before. Also nested formatting is not supported by telegram itself. Consider switching to MarkdownV2 or HTML for simplicity reasons.

Keywords

telegram

FAQs

Package last updated on 15 Apr 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