Conversion and formatting functions should check if in string context to avoid using HTML elements in formatting when in string context. See Init File Expansion Contexts: Normal, Preformatted, Code, String, Math.
To determine if in string context, the functions is in_string
:
$in_string =
$converter->in_string ()
¶Return true if in string context.
Example of use:
if ($converter->in_string()) { return "$mail_string ($text)"; } else { return $converter->html_attribute_class('a', [$cmdname]) ." href=\"mailto:$mail_string\">$text</a>"; }