]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.4.9: MediaWiki
authorHamatoma <author@hamatoma.de>
Tue, 2 Jul 2024 17:56:22 +0000 (19:56 +0200)
committerHamatoma <author@hamatoma.de>
Tue, 2 Jul 2024 17:57:07 +0000 (19:57 +0200)
- MediaWiki:
  - specialMacrosToHtml(): %mark()%: Aufruf von writeText() für die Interpretation des Textparameters

CHANGELOG.md
app/Helpers/MediaWiki.php
tests/Helpers/MediaWikiTest.php

index 12180dd6fdbfbdcae85440ca9136f64a828a1516..76c3427f76bb8b4d0efeb18fca121a24ad51d45b 100644 (file)
@@ -1,3 +1,8 @@
+# V 0.4.9: MediaWiki
+
+- MediaWiki:
+  - specialMacrosToHtml(): %mark()%: Aufruf von writeText() für die Interpretation des Textparameters
+
 # V 0.4.8: PageController
 
 - PageController:
index 123955a54e7c058fa20863d134c64a81473afdf4..4bc1cc7846c3d3652aeaf7365eca4398ef770868 100644 (file)
@@ -29,7 +29,7 @@ class MediaWiki extends MediaWikiBase
     function specialMacrosToHtml(string $body): string
     {
         $pos = 0;
-        // .............................1...1..2...23....3
+        // ..............................1...1..2...23....3
         $body = preg_replace_callback('/%(\w+)\((.*?)(\|.*?)?\)%/', function ($matches) {
             switch ($matches[1]) {
                 case 'date':
@@ -45,11 +45,16 @@ class MediaWiki extends MediaWikiBase
                     break;
                 case 'mark':
                     $mode = count($matches) > 3 ? substr($matches[3], 1) : 'info';
+                    $safe = $this->htmlBody;
+                    $this->htmlBody = '';
+                    $this->writeText($matches[2]);
+                    $text = $this->htmlBody;
+                    $this->htmlBody = $safe;
                     if (str_starts_with($mode, '.')) {
                         $mode = substr($mode, 1);
-                        $rc = "<span class=\"$mode\">$matches[2]</span>";
+                        $rc = "<span class=\"$mode\">$text</span>";
                     } else {
-                        $rc = "<span class=\"lkn-text-$mode\">$matches[2]</span>";
+                        $rc = "<span class=\"lkn-text-$mode\">$text</span>";
                     }
                     break;
                 case 'add':
index afe2edf04a98da8c379a53201d6903afd0d709ef..afc3c9ffef1cc59509fb6f0156485ad2d6685d07 100644 (file)
@@ -83,4 +83,17 @@ def
 
     }
 
+    public function testHeader(): void
+    {
+        $wiki = new MediaWiki();
+        $html = $wiki->toHtml("==U+x2B50;==");
+        $this->assertEquals("<h2>&#x2B50;</h2>", $html);
+    }
+    public function testMark(): void
+    {
+        $wiki = new MediaWiki();
+        $html = $wiki->toHtml("%mark(U+x2B50;|info2)%");
+        $this->assertEquals("<p><span class=\"lkn-text-info2\">&#x2B50;</span>\n</p>\n", $html);
+    }
+
 }