Guide
Working with formating options

Working With Formating Options

Formating options (parse mode) tgsnake uses @tgsnake/parser as a framework for parsing text.
We have 2 parse mode first html and markdown.

Markdown

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

HTML

<!-- bold text -->
<b>bold</b>
<strong>bold</strong>
<!-- italic text -->
<i>italic</i>
<em>italic</em>
<!-- strikethrough text -->
<s>strike</s>
<del>strike</del>
<!-- mono text -->
<code>code</code>
<!-- code block -->
<pre>
  <code>pre</code>
</pre>
<pre>
  <code language-javascript >pre</code>
</pre>
<!-- text with link -->
<a href="link">text</a>
<!-- underline text -->
<u>underline</u>
<!-- mark text as spoiler -->
<spoiler>spoiler</spoiler>
<sp>spoiler</sp>
<tg-spoiler>spoiler</tg-spoiler>
<span class="tg-spoiler">spoiler</span>
<!-- customize emoji (premium emoji) -->
<tg-emoji id="1"
  >text<tg-emoji>
    <span id="1" class="tg-emoji"
      >text<span>
        <!-- blockquote -->
        <blockquote>blockquote</blockquote>
        <blockquote expandable>expandable blockquote</blockquote></span
      ></span
    ></tg-emoji
  ></tg-emoji
>

For further information, please read the comparison table below.

Entities TypeMarkdown styleHTML styleDescription
Bold*text*<b>text</b> or <strong>text</strong>
Italic__text__<i>text</i> or <em>text</em>
Strikethrough~~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>

Escaping content.

To prevent content from being parsed as formatted text, you can follow these instructions.

On markdown mode, escaping content with add backslash (\) before markdown syntax.

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

On html mode, escaping content with replace < to &lt; , > to &rt; , & to &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;"