From 00d2b583588ea1c55e9b478809e8041d6ba98639 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 23 Jan 2011 16:29:30 -0800 Subject: [PATCH] fix a few issues with code blocks, ignore tags within blocks, fold multi-line blocks to one, also turn html br into two LFs. --- boot.php | 5 +++++ mod/item.php | 4 ++++ .../tiny_mce/plugins/bbcode/editor_plugin_src.js | 5 +++-- .../themes/advanced/skins/default/content.css | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index 05b33abd6e..45fd8d16fe 100644 --- a/boot.php +++ b/boot.php @@ -1687,6 +1687,11 @@ function activity_match($haystack,$needle) { if(! function_exists('get_tags')) { function get_tags($s) { $ret = array(); + + // ignore anything in a code block + + $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s); + if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) { foreach($match[1] as $match) { if(strstr($match,"]")) { diff --git a/mod/item.php b/mod/item.php index f964e7737d..feef7c95f8 100644 --- a/mod/item.php +++ b/mod/item.php @@ -165,7 +165,11 @@ function item_post(&$a) { } } + /** + * Fold multi-line [code] sequences + */ + $body = preg_replace('/\[\/code\]\s*\[code\]/m',"\n",$body); /** * Look for any tags and linkify them diff --git a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index 8728f0c0f3..f12975ba21 100644 --- a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -64,8 +64,8 @@ rep(//gi,"[u]"); rep(/]*>/gi,"[quote]"); rep(/<\/blockquote>/gi,"[/quote]"); - rep(/
/gi,"\n"); - rep(//gi,"\n"); + rep(/
/gi,"\n\n"); + rep(//gi,"\n\n"); rep(/
/gi,"\n"); rep(/

/gi,""); rep(/<\/p>/gi,"\n"); @@ -98,6 +98,7 @@ rep(/\[url\](.*?)\[\/url\]/gi,"$1"); rep(/\[img\](.*?)\[\/img\]/gi,""); rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"$2"); +// rep(/\[\/code\]\s*\[code\]/gi,"
"); // fold multiline code rep(/\[code\](.*?)\[\/code\]/gi,"$1"); rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"

$1
"); diff --git a/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/content.css b/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/content.css index 36f38aba29..444063a828 100644 --- a/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/content.css +++ b/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/content.css @@ -18,6 +18,18 @@ del {color:red; text-decoration:line-through} cite {border-bottom:1px dashed blue} acronym {border-bottom:1px dotted #CCC; cursor:help} abbr {border-bottom:1px dashed #CCC; cursor:help} +code { + font-family: Courier, monospace; + white-space: pre; + display: block; + overflow: auto; + border: 1px solid #444; + background: #EEE; + color: #444; + padding: 10px; + margin-top: 20px; +} + /* IE */ * html body {