mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-01-30 11:57:28 +01:00
Fix markup again. And add the option to repair fucked up nesting (and more) with HTML Tidy ($config['markup_repair_tidy'])
This commit is contained in:
parent
cae63cf65e
commit
4bed78fb32
@ -459,10 +459,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// "Wiki" markup syntax ($config['wiki_markup'] in pervious versions):
|
// "Wiki" markup syntax ($config['wiki_markup'] in pervious versions):
|
||||||
$config['markup'][] = array("/'''([^<]+?)'''/", "<strong>\$1</strong>");
|
$config['markup'][] = array("/'''(.+?)'''/", "<strong>\$1</strong>");
|
||||||
$config['markup'][] = array("/''([^<]+?)''/", "<em>\$1</em>");
|
$config['markup'][] = array("/''(.+?)''/", "<em>\$1</em>");
|
||||||
$config['markup'][] = array("/\*\*([^<]+?)\*\*/", "<span class=\"spoiler\">\$1</span>");
|
$config['markup'][] = array("/\*\*(.+?)\*\*/", "<span class=\"spoiler\">\$1</span>");
|
||||||
// $config['markup'][] = array("/^[ |\t]*==([^<]+?)==[ |\t]*$/m", "<span class=\"heading\">\$1</span>");
|
// $config['markup'][] = array("/^[ |\t]*==(.+?)==[ |\t]*$/m", "<span class=\"heading\">\$1</span>");
|
||||||
|
|
||||||
// Highlight PHP code wrapped in <code> tags (PHP 5.3+)
|
// Highlight PHP code wrapped in <code> tags (PHP 5.3+)
|
||||||
// $config['markup'][] = array(
|
// $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,
|
// 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
|
// Tinyboard only parses post markup when it needs to, and keeps post-markup HTML in the database. This
|
||||||
// will significantly impact performance when enabled.
|
// will significantly impact performance when enabled.
|
||||||
|
@ -1728,7 +1728,16 @@ function markup(&$body, $track_cites = false) {
|
|||||||
$body = preg_replace('/\s+$/', '', $body);
|
$body = preg_replace('/\s+$/', '', $body);
|
||||||
|
|
||||||
$body = preg_replace("/\n/", '<br/>', $body);
|
$body = preg_replace("/\n/", '<br/>', $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>|</body>.+$@', '', $body);
|
||||||
|
}
|
||||||
|
|
||||||
return $tracked_cites;
|
return $tracked_cites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user