Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@telegram.ts/formatters

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

@telegram.ts/formatters

Library for formatting text in HTML and MarkdownV2 for Telegram Bot API

unpublished
npmnpm
Version
0.3.0
Version published
Weekly downloads
250
-5.66%
Maintainers
1
Weekly downloads
 
Created
Source

@telegram.ts/formatters



Bot API NPM Version NPM Downloads

This library provides a set of functions for formatting text for use in Telegram messages. The functions can be used to format text with bold, italic, underline, strikethrough, inline code, code blocks, links and images.

💪 Installation

To install @telegram.ts/formatters, run:

npm install @telegram.ts/formatters

⭐️ Usage

const { bold, italic, underline, strikethrough, code, link, image, heading, paragraph, list, codeBlock } = require('@telegram.ts/formatters').html;

const message = `
${bold('Hello World!')}
${italic('This is an italicized text.')}
${underline('This is an underlined text.')}
${strikethrough('This text has a strikethrough.')}
${code('This is inline code.')}
${link('Click me!', 'https://example.com')}
${image('https://example.com/image.jpg', 'Image description')}
${heading('This is a heading.', 1)}
${paragraph('This is a paragraph.')}
${list(['Item 1', 'Item 2', 'Item 3'], true)}
${codeBlock('const x = 1;', 'javascript')}
`;

console.log(message);

This will output:

<b>Hello World!</b>
<i>This is an italicized text.</i>
<u>This is an underlined text.</u>
<s>This text has a strikethrough.</s>
<code>This is inline code.</code>
<a href="https://example.com">Click me!</a>
<img src="https://example.com/image.jpg" alt="Image description">
<h1>This is a heading.</h1>
This is a paragraph.

1. Item 1
2. Item 2
3. Item 3

📜 Functions

bold(text: string): string

Formats text in bold.

italic(text: string): string

Formats text in italic.

underline(text: string): string

Formats text with an underline.

strikethrough(text: string): string

Formats text with a strikethrough.

code(text: string): string

Formats text as inline code.

link(text: string, url: string): string

Formats a link with the specified text and URL.

image(url: string, alt: string): string

Formats an image with the specified URL and alt text.

heading(text: string, level: number = 1): string

Formats a heading with the specified text and level (1-6).

paragraph(text: string): string

Formats a paragraph of text.

list(items: string[], ordered: boolean = false): string

Formats a list with the specified items. If ordered is true, the list will be ordered.

codeBlock(code: string, language: string = ''): string

Formats a code block with the specified code and language (optional).

Keywords

telegram

FAQs

Package last updated on 16 May 2023

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