< Summary

Information
Class: TeleFlow.Telegram.Formatting.TelegramMarkdownV2
Assembly: TeleFlow.Telegram.Client
File(s): /_/src/TeleFlow.Telegram.Client/Formatting/TelegramMarkdownV2.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 35
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Create()100%11100%
Escape(...)100%11100%
UnsafeMarkup(...)100%11100%

File(s)

/_/src/TeleFlow.Telegram.Client/Formatting/TelegramMarkdownV2.cs

#LineLine coverage
 1namespace TeleFlow.Telegram.Formatting;
 2
 3/// <summary>
 4/// Creates safe MarkdownV2-formatted Telegram text for normal Bot API messages.
 5/// Plain values passed to the returned builder are escaped automatically.
 6/// </summary>
 7public static class TelegramMarkdownV2
 8{
 9    /// <summary>
 10    /// Creates a builder that renders Telegram-compatible MarkdownV2.
 11    /// </summary>
 12    public static TelegramTextBuilder Create()
 13    {
 714        return new TelegramTextBuilder(TelegramMarkdownV2TextRenderer.Instance);
 15    }
 16
 17    /// <summary>
 18    /// Escapes plain dynamic text for safe insertion into reviewed Telegram MarkdownV2 markup.
 19    /// </summary>
 20    public static string Escape(string text)
 21    {
 222        ArgumentNullException.ThrowIfNull(text);
 223        return TelegramMarkdownV2TextRenderer.Instance.EscapeText(text);
 24    }
 25
 26    /// <summary>
 27    /// Creates a MarkdownV2 formatted-text value from reviewed static markup.
 28    /// This bypasses escaping and structural validation and must never receive user-controlled input.
 29    /// </summary>
 30    public static TelegramFormattedText UnsafeMarkup(string markup)
 31    {
 232        ArgumentException.ThrowIfNullOrWhiteSpace(markup);
 233        return new TelegramFormattedText(markup, TelegramParseMode.MarkdownV2);
 34    }
 35}