1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-30 18:24:29 +01:00

Customizable markup syntax.

This commit is contained in:
Michael Save 2012-03-21 11:57:30 +11:00
parent 7e1ff9580d
commit 4afd2c7cb2
2 changed files with 29 additions and 9 deletions

View File

@ -42,7 +42,8 @@
'file_icons' => Array(), 'file_icons' => Array(),
'footer' => Array(), 'footer' => Array(),
'stylesheets' => Array(), 'stylesheets' => Array(),
'additional_javascript' => Array() 'additional_javascript' => Array(),
'markup' => Array()
); );
/* End ignore */ /* End ignore */
@ -319,8 +320,6 @@
// Automatically convert things like "..." to Unicode characters ("…") // Automatically convert things like "..." to Unicode characters ("…")
$config['auto_unicode'] = true; $config['auto_unicode'] = true;
// Use some Wiki-like syntax (''em'', '''strong''', ==Heading==, etc)
$config['wiki_markup'] = true;
// Whether to turn URLs into functional links // Whether to turn URLs into functional links
$config['markup_urls'] = true; $config['markup_urls'] = true;
@ -356,12 +355,32 @@
// This will make your imageboard more vulnerable to flood attacks. // This will make your imageboard more vulnerable to flood attacks.
$config['quick_reply'] = false; $config['quick_reply'] = false;
/*
* ====================
* Markup settings
* ====================
*/
// "Wiki" markup syntax ($config['wiki_markup'] in pervious versions):
$config['markup'][] = Array("/'''(.+?)'''/m", "<strong>\$1</strong>");
$config['markup'][] = Array("/''(.+?)''/m", "<em>\$1</em>");
$config['markup'][] = Array("/\*\*(.+?)\*\*/m", "<span class=\"spoiler\">\$1</span>");
$config['markup'][] = Array("/(^|\n)==(.+?)==\n?/m", "<span class=\"heading\">\$2</span>");
// Highlight PHP code wrapped in <code> tags (PHP 5.3.0+)
$config['markup'][] = Array(
'/^&lt;code&gt;(.+)&lt;\/code&gt;/s',
function($matches) {
return '<code>' . highlight_string(html_entity_decode($matches[1]), true) . '</code>';
}
);
/* /*
* ==================== * ====================
* Image settings * Image settings
* ==================== * ====================
*/ */
// For resizing, max thumbnail size // For resizing, max thumbnail size
$config['thumb_width'] = 255; $config['thumb_width'] = 255;
$config['thumb_height'] = 255; $config['thumb_height'] = 255;

View File

@ -1440,11 +1440,12 @@
$body = utf8tohtml($body); $body = utf8tohtml($body);
if($config['wiki_markup']) { foreach($config['markup'] as $markup) {
$body = preg_replace("/(^|\n)==(.+?)==\n?/m", "<span class=\"heading\">$2</span>", $body); if(is_string($markup[1])) {
$body = preg_replace("/'''(.+?)'''/m", "<strong>$1</strong>", $body); $body = preg_replace($markup[0], $markup[1], $body);
$body = preg_replace("/''(.+?)''/m", "<em>$1</em>", $body); } elseif(is_callable($markup[1])) {
$body = preg_replace("/\*\*(.+?)\*\*/m", "<span class=\"spoiler\">$1</span>", $body); $body = preg_replace_callback($markup[0], $markup[1], $body);
}
} }
if($config['markup_urls']) { if($config['markup_urls']) {