From: Alexander Ebert Date: Mon, 24 Jun 2019 16:57:26 +0000 (+0200) Subject: Improved the processing of HTML lacking paragraphs X-Git-Tag: 5.2.0_Alpha_1~17^2~2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=865470d0faeecad99f76d4f0ab771c9a89308002;p=GitHub%2FWoltLab%2FWCF.git Improved the processing of HTML lacking paragraphs --- diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index 2fc4735c78..d11fbd676d 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -73,6 +73,19 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor { 'a', 'kbd', 'woltlab-quote', 'woltlab-spoiler', 'pre', 'sub', 'sup' ]; + /** + * list of tag names that represent inline content in the HTML 5 standard + * @var string[] + */ + public static $inlineElements = [ + 'a', 'abbr', 'acronym', 'audio', 'b', 'bdi', 'bdo', 'big', 'br', 'button', + 'canvas', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', + 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'map', 'mark', 'meter', + 'noscript', 'object', 'output', 'picture', 'progress', 'q', 'ruby', 's', + 'samp', 'script', 'select', 'slot', 'small', 'span', 'strong', 'sub', 'sup', + 'svg', 'template', 'textarea', 'time', 'u', 'tt', 'var', 'video', 'wbr', + ]; + /** * list of embedded content grouped by type * @var array @@ -228,6 +241,9 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor { if ($node->nodeType === XML_ELEMENT_NODE && $node->nodeName === 'woltlab-metacode-marker') { $node = $appendToPreviousParagraph($node); } + else if ($node->nodeType === XML_ELEMENT_NODE && in_array($node->nodeName, self::$inlineElements)) { + $node = $appendToPreviousParagraph($node); + } else if ($node->nodeType === XML_TEXT_NODE) { // text node contains only a line break if ($node->textContent === "\n" || $node->textContent === "\r\n") {