phpbotgram

HtmlDecoration extends TextDecoration
in package

HTML decoration strategy.

Port of upstream aiogram/utils/text_decorations.pyHtmlDecoration.

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

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
string

quote()

Escape plain text for safe embedding in the target markup format.

public quote(string $value) : string
Parameters
$value : string
Return values
string

unparse()

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
string

blockquote()

protected blockquote(string $value) : string
Parameters
$value : string
Return values
string

bold()

protected bold(string $value) : string
Parameters
$value : string
Return values
string

code()

protected code(string $value) : string
Parameters
$value : string
Return values
string

customEmoji()

protected customEmoji(string $value, string $customEmojiId) : string
Parameters
$value : string
$customEmojiId : string
Return values
string

dateTime()

protected dateTime(string $value, int $unixTime, string|null $dateTimeFormat) : string
Parameters
$value : string
$unixTime : int
$dateTimeFormat : string|null
Return values
string

expandableBlockquote()

protected expandableBlockquote(string $value) : string
Parameters
$value : string
Return values
string

italic()

protected italic(string $value) : string
Parameters
$value : string
Return values
string
protected link(string $value, string $link) : string
Parameters
$value : string
$link : string
Return values
string

pre()

protected pre(string $value) : string
Parameters
$value : string
Return values
string

preLanguage()

protected preLanguage(string $value, string $language) : string
Parameters
$value : string
$language : string
Return values
string

spoiler()

protected spoiler(string $value) : string
Parameters
$value : string
Return values
string

strikethrough()

protected strikethrough(string $value) : string
Parameters
$value : string
Return values
string

underline()

protected underline(string $value) : string
Parameters
$value : string
Return values
string
On this page

Search results