npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tgsnake/parser

v2.1.0

Published

core framework for tgsnake for parsing message.

Downloads

142

Readme

@tgsnake/parser

core framework for tgsnake for parsing message.
example :

'**bold**';

it will be

[
  'bold',
  [
    {
      offset: 0,
      length: 4,
      type: 'bold',
    },
  ],
];

Quick Start

Breaking Changes in v2!
In this v2 is not supported gramjs framework by default! Unlike v1 which supports it, in v2 we fully use @tgsnake/core.

// index.ts
import { Parser } from '@tgsnake/parser'
import { Client } from '@tgsnake/core'
const client = new Client(...)

const entities = Parser.parse('**Hello World**,'markdown')

converting tgsnake entities to raw api

Parser.toRaw(client, entities);

converting raw entities to tgsnake entities

Parser.fromRaw(TypeMessageEntities);

available parseMode

markdown

'**bold**';
'__italic__';
'~~strike~~';
'`code`';
'```pre```';
'[text](link)';
'--underline--';
'||spoiler||';
'>blockquote';
'**>expandable blockquote';

Escaping
for escaping just add backslash (\) before markdown syntax.

'\\**bold\\**';
'\\__italic\\__';
'\\~~strike\\~~';
'\\`code\\`';
'\\```pre\\```';
'[text]\\(link)';
'\\--underline\\--';
'\\||spoiler\\||';
'\\>blockquote';
'\\**>expandable blockquote';

html

"<b>bold</b>" || "<strong>bold</strong>"
"<i>italic</i>" || "<em>italic</em>"
"<s>strike</s>" || "<del>strike</del>"
"<code>code</code>"
"<pre><code>pre</code></pre>"  || "<pre><code language-javascript >pre</code></pre>"
"<a href="link">text</a>"
"<u>underline</u>"
"<spoiler>spoiler</spoiler>" || "<sp>spoiler</sp>" || "<tg-spoiler>spoiler</tg-spoiler>" || '<span class="tg-spoiler">spoiler</span>'
"<tg-emoji id="1">text<tg-emoji>" || "<span id="1" class="tg-emoji">text<span>"
"<blockquote>blockquote</blockquote>"
"<blockquote expandable>expandable blockquote</blockquote>"

Escaping
for escaping replace < with &lt; , > with &rt; , & with &amp;

"&lt;b&rt;bold&lt;/b&rt;" || "&lt;strong&rt;bold&lt;/strong&rt;"
"&lt;i&rt;italic&lt;/i&rt;" || "&lt;em&rt;italic&lt;/em&rt;"
"&lt;s&rt;strike&lt;/s&rt;" || "&lt;del&rt;strike&lt;/del&rt;"
"&lt;code&rt;code&lt;/code&rt;"
"&lt;pre&rt;&lt;code&rt;pre&lt;/code&rt;&lt;/pre&rt;"  || "&lt;pre&rt;&lt;code language-javascript &rt;pre&lt;/code&rt;&lt;/pre&rt;"
"&lt;a href="link"&rt;text&lt;/a&rt;"
"&lt;u&rt;underline&lt;/u&rt;"
"&lt;spoiler&rt;spoiler&lt;/spoiler&rt;" || "&lt;sp&rt;spoiler&lt;/sp&rt;" || "&lt;tg-spoiler&rt;spoiler&lt;/tg-spoiler&rt;" || '&lt;span class="tg-spoiler"&rt;spoiler&lt;/span&rt;'
"&lt;blockquote&rt;blockquote&lt;/blockquote&rt;"

Available Formating Style

| Entity Type | Markdown style | HTML style | Description | | :-: | :-: | :-: | :-- | | Bold | *text* | <b>text</b> or <strong>text</strong> | | | Italic | __text__ | <i>text</i> or <em>text</em> | | | ~~Strike~~ | ~~text~~ | <s>text</s> or <del>text</del> | | | Code | `text` | <code>text</code> | | | Pre | ```text``` | <pre><code>text</code></pre> or <pre language-javascript><code>text</code></pre> | | | Link | [text](link) | <a href="link">text</a> | You can fill the link params with tg://user?id=123456 for mentioning user and tg://emoji?id=123456 for custom emoji. | | Underline | --text-- | <u>text</u> | | | Spoiler | \|\|text\|\| | <spoiler>text</spoiler> or <sp>text</sp> or <tg-spoiler>text</tg-spoiler> or <span class="tg-spoiler">text</span> | | | Custom Emoji | [text](tg://emoji?id=123456) | <tg-emoji id="123456">text</tg-emoji> or <emoji id="123456">text</emoji> or <span class="tg-emoji" id="123456">text</span> | HTML tag has 2 way to define the emojiId. First using id attribute and seconds use emojiId attribute. | | Blockquote | >text | <blockquote>text</blockquote> | |

Build with ♥️ by tgsnake dev.