< Summary

Information
Class: TeleFlow.Telegram.Formatting.TelegramHtml
Assembly: TeleFlow.Telegram.Client
File(s): /_/src/TeleFlow.Telegram.Client/Formatting/TelegramHtml.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 36
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/TelegramHtml.cs

#LineLine coverage
 1namespace TeleFlow.Telegram.Formatting;
 2
 3/// <summary>
 4/// Creates safe HTML-formatted Telegram text for normal Bot API messages.
 5/// Plain values passed to the returned builder are escaped automatically.
 6/// </summary>
 7public static class TelegramHtml
 8{
 9    /// <summary>
 10    /// Creates a builder that renders Telegram-compatible HTML.
 11    /// </summary>
 12    public static TelegramTextBuilder Create()
 13    {
 1514        return new TelegramTextBuilder(TelegramHtmlTextRenderer.Instance);
 15    }
 16
 17    /// <summary>
 18    /// Escapes a dynamic value for insertion into reviewed Telegram HTML markup.
 19    /// Quote delimiters are encoded so the value cannot leave a quoted attribute.
 20    /// </summary>
 21    public static string Escape(string text)
 22    {
 423        ArgumentNullException.ThrowIfNull(text);
 424        return TelegramHtmlEscaper.EscapeInterpolation(text);
 25    }
 26
 27    /// <summary>
 28    /// Creates an HTML formatted-text value from reviewed static markup.
 29    /// This bypasses escaping and structural validation and must never receive user-controlled input.
 30    /// </summary>
 31    public static TelegramFormattedText UnsafeMarkup(string markup)
 32    {
 533        ArgumentException.ThrowIfNullOrWhiteSpace(markup);
 534        return new TelegramFormattedText(markup, TelegramParseMode.Html);
 35    }
 36}