Skip to main content

Built and signed on GitHub Actions

Library for formatting text for Telegram Bot API

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (0.1.5)
function format
format(
stringParts: TemplateStringsArray,
...strings: Stringable[],
): FormattableString

Template literal that helps construct message entities for text formatting.

Documentation

Use if you want to strip all of the indentation from the beginning of each line.

NOTE: for format with arrays use it with join helper -

format`${join(["test", "other"], (x) => format`${bold(x)}`, "\n")}`

Examples

Example 1

bot.api.sendMessage({
     chat_id: 12321,
     text: format`${bold`Hi!`}
         Can ${italic(`you`)} help ${spoiler`me`}?
             Can you give me a ${link("star", "https://github.com/gramiojs/gramio")}?`
})

format

Parameters

stringParts: TemplateStringsArray
...strings: Stringable[]

Return Type

Add Package

deno add jsr:@gramio/format

Import symbol

import { format } from "@gramio/format";

---- OR ----

Import directly with a jsr specifier

import { format } from "jsr:@gramio/format";

Add Package

npx jsr add @gramio/format

Import symbol

import { format } from "@gramio/format";

Add Package

yarn dlx jsr add @gramio/format

Import symbol

import { format } from "@gramio/format";

Add Package

pnpm dlx jsr add @gramio/format

Import symbol

import { format } from "@gramio/format";

Add Package

bunx jsr add @gramio/format

Import symbol

import { format } from "@gramio/format";