public static function markdown_2_bbcode($text)
{
$text = htmlspecialchars_decode($text);
$text = preg_replace('/\*\*((?:(?!\*\*).)+)\*\*/', '\1', $text);
$text = preg_replace('/\*((?:(?!\*).)+)\*/', '\1', $text);
$text = preg_replace('/##((?:(?!##).)+)(?:##)?/', '\[size=16]\1\[\/size]', $text);
$text = preg_replace('/!!\[(?:(?!\]).)*\]\(((?:(?!\)).)+)\)/', '
', $text);$text = preg_replace('/!\[(?:(?!\]).)*\]\(((?:(?!\)).)+)\)/', '', $text);
$text = preg_replace('/\[((?:(?!\]).)+)\]\(((?:(?!\)).)+)\)/', '', $text);
$text = preg_replace('/{{{(.+?)}}}/s', '
\1', $text);
$text = preg_replace('/^>((?:(?!\n\n).)+)/ms', '
', $text);\1
preg_match_all('/(^\d+\. .+\n?)+/m', $text, $num_list);
if ($num_list[0])
{
foreach ($num_list[0] AS $value)
{
$new_value = trim(preg_replace('/^\d+\. (.+)/m', '[*]\1[/*]', $value));
$text = str_replace($value, "
}
}
preg_match_all('/(^- .+\n?)+/m', $text, $nor_list);
if ($nor_list[0])
{
foreach ($nor_list[0] AS $value)
{
$new_value = trim(preg_replace('/^- (.+)/m', '[*]\1[/*]', $value));
$text = str_replace($value, "
}
}
return htmlspecialchars($text);
}