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':
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':
}
+ public function testHeader(): void
+ {
+ $wiki = new MediaWiki();
+ $html = $wiki->toHtml("==U+x2B50;==");
+ $this->assertEquals("<h2>⭐</h2>", $html);
+ }
+ public function testMark(): void
+ {
+ $wiki = new MediaWiki();
+ $html = $wiki->toHtml("%mark(U+x2B50;|info2)%");
+ $this->assertEquals("<p><span class=\"lkn-text-info2\">⭐</span>\n</p>\n", $html);
+ }
+
}