HtmlDecoration
extends TextDecoration
in package
HTML decoration strategy.
Port of upstream aiogram/utils/text_decorations.py — HtmlDecoration.
Special characters in plain text are HTML-escaped via quote().
Each entity type wraps its inner text in the appropriate HTML tag.
NOTE: This implementation uses ENT_QUOTES rather than upstream's
html.escape(quote=False). Upstream parity for non-quote characters is
preserved; escaping " and ' is defense-in-depth against XSS when
the rendered HTML is consumed by webhook dashboards / web frontends.
Table of Contents
Properties
- $instance : self|null
Methods
- applyEntity() : string
- Apply the decoration corresponding to a single MessageEntity to $text.
- instance() : self
- quote() : string
- Escape plain text for safe embedding in the target markup format.
- unparse() : string
- Reconstruct a decorated string from $text and its entity list.
- blockquote() : string
- bold() : string
- code() : string
- customEmoji() : string
- dateTime() : string
- expandableBlockquote() : string
- italic() : string
- link() : string
- pre() : string
- preLanguage() : string
- spoiler() : string
- strikethrough() : string
- underline() : string
Properties
$instance
private
static self|null
$instance
= null
Methods
applyEntity()
Apply the decoration corresponding to a single MessageEntity to $text.
public
final applyEntity(MessageEntity $entity, string $text) : string
$text is already the inner (possibly recursively-decorated) substring.
Parameters
- $entity : MessageEntity
- $text : string
Return values
stringinstance()
public
static instance() : self
Return values
selfquote()
Escape plain text for safe embedding in the target markup format.
public
quote(string $value) : string
Parameters
- $value : string
Return values
stringunparse()
Reconstruct a decorated string from $text and its entity list.
public
final unparse(string $text[, null|array<int, MessageEntity> $entities = null ]) : string
Mirrors upstream TextDecoration.unparse().
Parameters
- $text : string
- $entities : null|array<int, MessageEntity> = null
Return values
stringblockquote()
protected
blockquote(string $value) : string
Parameters
- $value : string
Return values
stringbold()
protected
bold(string $value) : string
Parameters
- $value : string
Return values
stringcode()
protected
code(string $value) : string
Parameters
- $value : string
Return values
stringcustomEmoji()
protected
customEmoji(string $value, string $customEmojiId) : string
Parameters
- $value : string
- $customEmojiId : string
Return values
stringdateTime()
protected
dateTime(string $value, int $unixTime, string|null $dateTimeFormat) : string
Parameters
- $value : string
- $unixTime : int
- $dateTimeFormat : string|null
Return values
stringexpandableBlockquote()
protected
expandableBlockquote(string $value) : string
Parameters
- $value : string
Return values
stringitalic()
protected
italic(string $value) : string
Parameters
- $value : string
Return values
stringlink()
protected
link(string $value, string $link) : string
Parameters
- $value : string
- $link : string
Return values
stringpre()
protected
pre(string $value) : string
Parameters
- $value : string
Return values
stringpreLanguage()
protected
preLanguage(string $value, string $language) : string
Parameters
- $value : string
- $language : string
Return values
stringspoiler()
protected
spoiler(string $value) : string
Parameters
- $value : string
Return values
stringstrikethrough()
protected
strikethrough(string $value) : string
Parameters
- $value : string
Return values
stringunderline()
protected
underline(string $value) : string
Parameters
- $value : string