public function CodeTagPlugin::prepare in Extensible BBCode 8.3
Same name and namespace in other branches
- 4.0.x standard/src/Plugin/XBBCode/CodeTagPlugin.php \Drupal\xbbcode_standard\Plugin\XBBCode\CodeTagPlugin::prepare()
Transform an elements' content, to armor against other filters.
- Use the inner content if all children will be rendered. (This just means the children's own ::prepare() functions are used.)
- Use $tag->getSource() if no children will be rendered.
- Traverse the tag's descendants for more complex cases.
Parameters
string $content: The content, after applying inner transformations.
\Drupal\xbbcode\Parser\Tree\TagElementInterface $tag: The original tag element.
Return value
string The prepared output.
Overrides TagPluginBase::prepare
File
- standard/
src/ Plugin/ XBBCode/ CodeTagPlugin.php, line 27
Class
- CodeTagPlugin
- Prints raw code.
Namespace
Drupal\xbbcode_standard\Plugin\XBBCodeCode
public function prepare(string $content, TagElementInterface $tag) : string {
// Escape HTML characters, to prevent other filters from creating entities.
// Use $tag->getSource() instead of $content, to discard the ::prepare()
// output of nested tags (because they will not be rendered).
return Utf8::encode($tag
->getSource(), '<>&"\'');
}