*
* @param string $name bbcode identifier
* @param array $attributes list of attributes
+ * @param \DOMElement $element element
* @return string parsed bbcode
*/
- public function getHtmlOutput($name, array $attributes) {
+ public function getHtmlOutput($name, array $attributes, \DOMElement $element) {
if (isset($this->bbcodes[$name])) {
+ $bbcode = $this->bbcodes[$name];
+ if ($bbcode->isSourceCode) {
+ array_unshift($attributes, $element->textContent);
+ }
+
$openingTag = ['attributes' => $attributes, 'name' => $name];
$closingTag = ['name' => $name];
- if ($this->bbcodes[$name]->getProcessor()) {
+ if ($bbcode->getProcessor()) {
/** @var IBBCode $processor */
- $processor = $this->bbcodes[$name]->getProcessor();
+ $processor = $bbcode->getProcessor();
return $processor->getParsedTag($openingTag, '<!-- META_CODE_INNER_CONTENT -->', $closingTag, $this);
}
else {
$attributes = $element->getAttribute('data-attributes');
$nodeIdentifier = StringUtil::getRandomID();
+
+ $element = $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier);
+
$htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [
'name' => $name,
- 'attributes' => $htmlNodeProcessor->parseAttributes($attributes)
+ 'attributes' => $htmlNodeProcessor->parseAttributes($attributes),
+ 'element' => $element
]);
-
- $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier);
}
}
public function replaceTag(array $data) {
HtmlBBCodeParser::getInstance()->setOutputType($this->outputType);
- return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes']);
+ return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes'], $data['element']);
}
}