{"id":24894851,"url":"https://github.com/ayocord-js/tg-text-formatter","last_synced_at":"2025-03-27T15:23:00.521Z","repository":{"id":260962079,"uuid":"882829165","full_name":"ayocord-js/tg-text-formatter","owner":"ayocord-js","description":"Telegram markdown formatter. Helpful for work with message content in telegram","archived":false,"fork":false,"pushed_at":"2024-11-04T19:57:22.000Z","size":204,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T21:48:46.011Z","etag":null,"topics":["library","module","string","telegram","tg","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/tg-text-formatter","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayocord-js.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-03T21:28:47.000Z","updated_at":"2024-12-29T19:07:39.000Z","dependencies_parsed_at":"2024-11-03T22:27:17.321Z","dependency_job_id":"c00b8f42-ecd5-439a-8f4f-7022f7a98311","html_url":"https://github.com/ayocord-js/tg-text-formatter","commit_stats":null,"previous_names":["ayomits/tg-text-formatter","ayocord-js/tg-text-formatter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayocord-js%2Ftg-text-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayocord-js%2Ftg-text-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayocord-js%2Ftg-text-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayocord-js%2Ftg-text-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayocord-js","download_url":"https://codeload.github.com/ayocord-js/tg-text-formatter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245868724,"owners_count":20685695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","module","string","telegram","tg","typescript"],"created_at":"2025-02-01T19:14:54.234Z","updated_at":"2025-03-27T15:23:00.499Z","avatar_url":"https://github.com/ayocord-js.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tg Text Formatter\n\nHello! Welcome to the **tg-text-formatter** package for Telegram text markdown. This library provides convenient methods for formatting text without the hassle of manual markdown syntax.\n\n## Installation\n\nYou can easily install this package via npm or yarn:\n\n```bash\nnpm i tg-text-formatter\n```\n\n```bash\nyarn add tg-text-formatter\n```\n\n## Tests of this Library\n\n\u003cimg src=\"./tests.png\"\u003e\n\n## Ways to Use\n\nThere are two ways to use this library:\n\n1. Using classes\n2. Using methods\n\n# TelegramMarkdown\n\n## Using Class\n\n```ts\nimport { TelegramMarkdown } from \"tg-text-formatter\";\n\nconsole.log(TelegramMarkdown.bold(\"idk\")); // **idk**\nconsole.log(TelegramMarkdown.cursive(\"idk\")); // __idk__\nconsole.log(TelegramMarkdown.boldCursive(\"idk\")); // **__idk__**\nconsole.log(TelegramMarkdown.crossedOut(\"idk\")); // ~~idk~~\nconsole.log(TelegramMarkdown.monospace(\"idk\")); // `idk`\n\n/**\n * Code with language\n */\nconsole.log(TelegramMarkdown.code(\"console.log(`idk`)\", \"ts\")); // ```ts\\nidk```\n\n/**\n * Code without language\n */\nconsole.log(TelegramMarkdown.code(\"console.log(`idk`)\")); // ```\\nidk```\nconsole.log(TelegramMarkdown.spoiler(\"idk\")); // ||idk||\n```\n\n## Using Methods\n\n```ts\nimport {\n    bold,\n    cursive,\n    boldCursive,\n    crossedOut,\n    monospace,\n    code,\n    spoiler,\n} from \"tg-text-formatter\";\n\nconsole.log(bold(\"idk\")); // **idk**\nconsole.log(cursive(\"idk\")); // __idk__\nconsole.log(boldCursive(\"idk\")); // **__idk__**\nconsole.log(crossedOut(\"idk\")); // ~~idk~~\nconsole.log(monospace(\"idk\")); // `idk`\n\n/**\n * Code with language\n */\nconsole.log(code(\"console.log(`idk`)\", \"ts\")); // ```ts\\nidk```\n\n/**\n * Code without language\n */\nconsole.log(code(\"console.log(`idk`)\")); // ```\\nidk```\nconsole.log(spoiler(\"idk\")); // ||idk||\n```\n\n# TelegramMentionParsers\n\nThe **TelegramMentionParsers** class provides methods for detecting and parsing Telegram mentions within text.\n\n## Using TelegramMentionParsers\n\n```ts\nimport { TelegramMentionParsers } from \"tg-text-formatter\";\n\nconsole.log(TelegramMentionParsers.isMention(\"@Stickers\")); // true\nconsole.log(TelegramMentionParsers.isMention(\"@@Stickers\")); // false\nconsole.log(TelegramMentionParsers.mentions(\"@Stickers @akakuke\", true)); // [\"@Stickers\", \"@akakuke\"]\nconsole.log(TelegramMentionParsers.mentions(\"@Stickers @@akakuke\", true)); // [\"@Stickers\"]\nconsole.log(TelegramMentionParsers.mentions(\"Stickers akakuke\", true)); // []\nconsole.log(TelegramMentionParsers.isLinkMention(\"Check this link: https://t.me/username\")); // true\n```\n\n## Methods in TelegramMentionParsers\n\n- `isMention(content: string): boolean` - Checks if the content contains a valid mention.\n- `mentions(content: string, mentions?: boolean): string[]` - Extracts mentions from the content. If `mentions` is true, it returns the mentions with the \"@\" symbol; otherwise, it returns without the \"@\".\n- `isLinkMention(content: string): boolean` - Checks if the content contains a valid Telegram link.\n\n# TelegramMarkdownParser\n\nThe **TelegramMarkdownParser** class provides methods for detecting and parsing various markdown styles in Telegram text.\n\n## Methods in TelegramMarkdownParser\n\n- `isBold(text: string): boolean` - Checks if the text is bold.\n- `parseBold(text: string, markdown = false): string[]` - Parses bold text. Returns the formatted text if `markdown` is true, otherwise returns the plain text.\n- `isCursive(text: string): boolean` - Checks if the text is cursive.\n- `parseCursive(text: string, markdown = false): string[]` - Parses cursive text.\n- `isMonospace(text: string): boolean` - Checks if the text is monospace.\n- `parseMonospace(text: string, markdown = false): string[]` - Parses monospace text.\n- `isCode(text: string): boolean` - Checks if the text is a code block.\n- `parseCode(text: string, markdown = false): string[]` - Parses code blocks.\n- `isSpoiler(text: string): boolean` - Checks if the text is a spoiler.\n- `parseSpoiler(text: string, markdown = false): string[]` - Parses spoilers.\n- `isLink(text: string): boolean` - Checks if the text contains a markdown link.\n- `parseLink(text: string): boolean` - Parses markdown links.\nNow you can easily format your Telegram messages and manage mentions with this comprehensive library!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayocord-js%2Ftg-text-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayocord-js%2Ftg-text-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayocord-js%2Ftg-text-formatter/lists"}