support [b], [i], [spoiler], and [entry] bbcode tags in formatting

This commit is contained in:
mappu 2015-09-06 11:48:40 +12:00
parent 87dd96adbd
commit 5ddd86e4aa

View File

@ -116,6 +116,10 @@ function text2html($sz) {
$base = preg_replace('~^=+(.+)=+~m', '<strong>\\1</strong>', $base); $base = preg_replace('~^=+(.+)=+~m', '<strong>\\1</strong>', $base);
$base = preg_replace('~(https?://[^ \\r\\n\\t]+)~i', '<a href="\\1">\\1</a>', $base); $base = preg_replace('~(https?://[^ \\r\\n\\t]+)~i', '<a href="\\1">\\1</a>', $base);
$base = preg_replace('~\\[b\\](.+?)\\[/b\\]~m', '<strong>\\1</strong>', $base);
$base = preg_replace('~\\[i\\](.+?)\\[/i\\]~m', '<i>\\1</i>', $base);
$base = preg_replace('~\\[spoiler\\](.+?)\\[/spoiler\\]~m', '<span class="spoiler">\\1</span>', $base);
$base = preg_replace('~\\[entry=([^\\]]+?)\\](.+?)\\[/entry\\]~m', '<a href="\\1.html">\\2</a>', $base);
$btparts = explode('`', $base); $btparts = explode('`', $base);
if (count($btparts) > 1 && (count($btparts) % 2)) { if (count($btparts) > 1 && (count($btparts) % 2)) {