From: Hamatoma Date: Tue, 2 Jul 2024 17:56:22 +0000 (+0200) Subject: V 0.4.9: MediaWiki X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=e3039cbea29be3f05999f5b7df5c18b6ac02cbc9;p=gadeku.git V 0.4.9: MediaWiki - MediaWiki: - specialMacrosToHtml(): %mark()%: Aufruf von writeText() für die Interpretation des Textparameters --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 12180dd..76c3427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/app/Helpers/MediaWiki.php b/app/Helpers/MediaWiki.php index 123955a..4bc1cc7 100644 --- a/app/Helpers/MediaWiki.php +++ b/app/Helpers/MediaWiki.php @@ -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 = "$matches[2]"; + $rc = "$text"; } else { - $rc = "$matches[2]"; + $rc = "$text"; } break; case 'add': diff --git a/tests/Helpers/MediaWikiTest.php b/tests/Helpers/MediaWikiTest.php index afe2edf..afc3c9f 100644 --- a/tests/Helpers/MediaWikiTest.php +++ b/tests/Helpers/MediaWikiTest.php @@ -83,4 +83,17 @@ def } + public function testHeader(): void + { + $wiki = new MediaWiki(); + $html = $wiki->toHtml("==U+x2B50;=="); + $this->assertEquals("

", $html); + } + public function testMark(): void + { + $wiki = new MediaWiki(); + $html = $wiki->toHtml("%mark(U+x2B50;|info2)%"); + $this->assertEquals("

\n

\n", $html); + } + }