Convert `[mark]` into `<mark>`
authorAlexander Ebert <ebert@woltlab.com>
Sun, 25 Jun 2023 12:03:26 +0000 (14:03 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 25 Jun 2023 12:03:26 +0000 (14:03 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/metacode/converter/MarkMetacodeConverter.class.php [new file with mode: 0644]

index d8ec2071511e57167becd58728f21cd1220741bc..f87ae14ff4cd0f68e4c9b9283bee231cd0bd0517 100644 (file)
@@ -42,7 +42,7 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor
             'woltlabSuiteMedia',
         ],
         'li' => ['text-center', 'text-justify', 'text-right'],
-        'mark' => ['marker-danger', 'marker-information', 'marker-success', 'marker-warning'],
+        'mark' => ['marker-error', 'marker-information', 'marker-success', 'marker-warning'],
         'p' => ['text-center', 'text-justify', 'text-right'],
         'pre' => ['woltlabHtml'],
         'td' => ['text-center', 'text-justify', 'text-right'],
diff --git a/wcfsetup/install/files/lib/system/html/metacode/converter/MarkMetacodeConverter.class.php b/wcfsetup/install/files/lib/system/html/metacode/converter/MarkMetacodeConverter.class.php
new file mode 100644 (file)
index 0000000..2f31240
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+namespace wcf\system\html\metacode\converter;
+
+/**
+ * Converts the mark bbcode into `<mark>`.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2023 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.0
+ */
+final class MarkMetacodeConverter extends AbstractMetacodeConverter
+{
+    /**
+     * @inheritDoc
+     */
+    public function convert(\DOMDocumentFragment $fragment, array $attributes)
+    {
+        $element = $fragment->ownerDocument->createElement('mark');
+        $element->setAttribute('class', $attributes[0]);
+        $element->appendChild($fragment);
+
+        return $element;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function validateAttributes(array $attributes)
+    {
+        if (\count($attributes) !== 1) {
+            return false;
+        }
+
+        return true;
+    }
+}