diff --git a/inc/config.php b/inc/config.php index 9f68d04b..f9dc9912 100644 --- a/inc/config.php +++ b/inc/config.php @@ -459,10 +459,10 @@ */ // "Wiki" markup syntax ($config['wiki_markup'] in pervious versions): - $config['markup'][] = array("/'''([^<]+?)'''/", "\$1"); - $config['markup'][] = array("/''([^<]+?)''/", "\$1"); - $config['markup'][] = array("/\*\*([^<]+?)\*\*/", "\$1"); - // $config['markup'][] = array("/^[ |\t]*==([^<]+?)==[ |\t]*$/m", "\$1"); + $config['markup'][] = array("/'''(.+?)'''/", "\$1"); + $config['markup'][] = array("/''(.+?)''/", "\$1"); + $config['markup'][] = array("/\*\*(.+?)\*\*/", "\$1"); + // $config['markup'][] = array("/^[ |\t]*==(.+?)==[ |\t]*$/m", "\$1"); // Highlight PHP code wrapped in tags (PHP 5.3+) // $config['markup'][] = array( @@ -472,6 +472,10 @@ // } // ); + // Repair markup with HTML Tidy. This may be slower, but most if the time it solves nesting mistakes. + // Tinyboad, at the time of writing this, can not prevent out-of-order markup tags (eg. "**''test**''). + $config['markup_repair_tidy'] = false; + // Always regenerate markup. This isn't recommended and should only be used for debugging; by default, // Tinyboard only parses post markup when it needs to, and keeps post-markup HTML in the database. This // will significantly impact performance when enabled. diff --git a/inc/functions.php b/inc/functions.php index d4a5766a..d006d0ad 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1728,7 +1728,16 @@ function markup(&$body, $track_cites = false) { $body = preg_replace('/\s+$/', '', $body); $body = preg_replace("/\n/", '
', $body); - + + if ($config['markup_repair_tidy']) { + $tidy = new tidy(); + $body = $tidy->repairString($body, array( + 'doctype' => 'omit' + )); + $body = str_replace("\n", '', $body); + $body = preg_replace('@^.+|.+$@', '', $body); + } + return $tracked_cites; }