Telegram Markdown Parser By TechFlecks icon

Telegram Markdown Parser By TechFlecks

Convert standard Markdown to Telegram MarkdownV2 format - By TechFlecks

Overview

This node converts standard Markdown text into Telegram's MarkdownV2 format, which is a stricter and more specific markdown variant used by Telegram for message formatting. It supports converting typical markdown syntax, optionally converting HTML tags to Telegram MarkdownV2 equivalents, escaping special characters that could break Telegram formatting, and validating if a given text is properly formatted for Telegram MarkdownV2.

Common scenarios where this node is beneficial include:

  • Preparing user-generated or external markdown content for safe and correct display in Telegram messages.
  • Automatically escaping text to prevent formatting errors when sending plain text in Telegram.
  • Validating Telegram MarkdownV2 strings before sending them to ensure they won't cause errors or display issues.

Practical examples:

  • Converting a blog post excerpt written in standard markdown into Telegram-compatible markdown for sharing in a Telegram channel.
  • Escaping user input that might contain special characters so it can be safely sent as a Telegram message without unintended formatting.
  • Checking if a Telegram message string has unmatched formatting markers or invalid URLs before sending.

Properties

Name Meaning
Input Text The markdown text to convert to Telegram MarkdownV2 format.
Conversion Options Collection of options controlling the conversion behavior:
- Preserve Line Breaks Whether to preserve line breaks in the converted text (true/false).
- Convert HTML Tags Whether to convert HTML tags (like <b>, <i>, <u>) to Telegram MarkdownV2 equivalents (true/false).
- Strict Mode Whether to use strict mode that fails on unsupported markdown features (true/false).
- Auto Escape Special Characters Whether to automatically escape special characters that could break Telegram formatting (true/false).

Output

The node outputs JSON objects with fields depending on the selected operation:

  • Convert to Telegram MarkdownV2:

    {
      "originalText": "<input markdown>",
      "telegramMarkdown": "<converted Telegram MarkdownV2 text>",
      "operation": "convertToTelegramMd",
      "processedBy": "TechFlecks Telegram Markdown Parser"
    }
    

    The telegramMarkdown field contains the input markdown converted to Telegram MarkdownV2 format.

  • Escape Text for Telegram:

    {
      "originalText": "<input text>",
      "escapedText": "<text with special characters escaped>",
      "operation": "escapeForTelegram",
      "processedBy": "TechFlecks Telegram Markdown Parser"
    }
    

    The escapedText field contains the input text with all Telegram special characters escaped.

  • Validate Telegram MarkdownV2:

    {
      "originalText": "<input Telegram MarkdownV2 text>",
      "isValid": true|false,
      "errors": [<list of error messages>],
      "warnings": [<list of warning messages>],
      "suggestions": [<list of suggestions>],
      "operation": "validateTelegramMd",
      "processedBy": "TechFlecks Telegram Markdown Parser"
    }
    

    This output provides detailed validation results about the correctness of the Telegram MarkdownV2 formatting.

The node does not output binary data.

Dependencies

  • No external services or APIs are required.
  • The node relies on internal logic implemented in the bundled code for parsing and converting markdown.
  • No special environment variables or credentials are needed.

Troubleshooting

  • Common Issues:

    • Unmatched formatting markers (e.g., unpaired asterisks or underscores) causing Telegram to reject or misrender messages.
    • Invalid URL formats in markdown links that do not start with http://, https://, or tg://.
    • Nested markdown formatting that Telegram MarkdownV2 does not support well.
    • Special characters not escaped properly leading to broken formatting.
  • Error Messages:

    • "Unknown operation: <operation>": Occurs if an unsupported operation is selected. Ensure the operation is one of the supported ones: convert, escape, or validate.
    • Validation errors listing unmatched formatting markers or unescaped special characters indicate the input text needs correction or escaping.
  • Resolutions:

    • Use the "Escape Text for Telegram" operation to automatically escape problematic characters.
    • Validate your Telegram MarkdownV2 text using the "Validate Telegram MarkdownV2" operation before sending.
    • Avoid nesting different markdown styles inside each other.
    • Ensure URLs in markdown links are valid and start with supported schemes.

Links and References

Discussion