From d11dad30558802a52d5e8656e33a1baaacc80b08 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 13 Mar 2012 16:00:25 +0000 Subject: [PATCH 1/4] sup/sub support in bbcode --- ext/bbcode/main.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 843e03f0..e0e35fb3 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -15,6 +15,8 @@ *
  • [i]italic[/i] *
  • [u]underline[/u] *
  • [s]strikethrough[/s] + *
  • [sup]superscript[/sup] + *
  • [sub]subscript[/sub] *
  • [[wiki article]] *
  • [[wiki article|with some text]] *
  • [quote]text[/quote] @@ -34,6 +36,8 @@ class BBCode extends FormatterExtension { $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text); $text = preg_replace("/\[s\](.*?)\[\/s\]/s", "\\1", $text); + $text = preg_replace("/\[sup\](.*?)\[\/sup\]/s", "\\1", $text); + $text = preg_replace("/\[sub\](.*?)\[\/sub\]/s", "\\1", $text); $text = preg_replace("/>>(\d+)(#c?(\d+))?/s", ">>\\1\\2", $text); $text = preg_replace("/(^|\s)#(\d+)/s", "\\1#\\2", $text); $text = preg_replace("/>>([^\d].+)/", "
    \\1
    ", $text); From c887580074bfbea81cf677e54bb394d85f0c1276 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 13 Mar 2012 16:01:03 +0000 Subject: [PATCH 2/4] with no more wordwrap, there's no need for unwrap --- ext/bbcode/main.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index e0e35fb3..b684be12 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -27,10 +27,6 @@ class BBCode extends FormatterExtension { public function format(/*string*/ $text) { - $text = preg_replace_callback("/(\[img\]https?:\/\/.*?\[\/img\])/s", array($this, "unwrap"), $text); - $text = preg_replace_callback("/(\[url=(?:https?|ftp|irc|mailto):\/\/.*?\])/s", array($this, "unwrap"), $text); - $text = preg_replace_callback("/(\[url\](?:https?|ftp|irc|mailto):\/\/.*?\[\/url\])/s", array($this, "unwrap"), $text); - $text = $this->extract_code($text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); @@ -70,10 +66,6 @@ class BBCode extends FormatterExtension { return $text; } - private function unwrap($matches) { - return str_replace(' ', '', $matches[1]); - } - public function strip(/*string*/ $text) { $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); From e31b6af28b0fe9da42ebec8f8cd6ca4be5214b9b Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 13 Mar 2012 16:01:13 +0000 Subject: [PATCH 3/4] site:// protocol support --- ext/bbcode/main.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index b684be12..87eea7c8 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -28,6 +28,7 @@ class BBCode extends FormatterExtension { public function format(/*string*/ $text) { $text = $this->extract_code($text); + $text = preg_replace("/site:\/\//s", make_http(get_base_href())."/", $text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text); @@ -37,8 +38,8 @@ class BBCode extends FormatterExtension { $text = preg_replace("/>>(\d+)(#c?(\d+))?/s", ">>\\1\\2", $text); $text = preg_replace("/(^|\s)#(\d+)/s", "\\1#\\2", $text); $text = preg_replace("/>>([^\d].+)/", "
    \\1
    ", $text); - $text = preg_replace("/\[url=((?:https?|ftp|irc|mailto):\/\/.*?)\](.*?)\[\/url\]/s", "\\2", $text); - $text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto):\/\/.*?)\[\/url\]/s", "\\1", $text); + $text = preg_replace("/\[url=((?:https?|ftp|irc|mailto|site):\/\/.*?)\](.*?)\[\/url\]/s", "\\2", $text); + $text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto|site):\/\/.*?)\[\/url\]/s", "\\1", $text); $text = preg_replace("/\[email\](.*?)\[\/email\]/s", "\\1", $text); $text = preg_replace("/\[img\](https?:\/\/.*?)\[\/img\]/s", "", $text); $text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "\\2", $text); From b4fb667eaa9a1f8119b86a7dda1345b87708239e Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 13 Mar 2012 16:04:50 +0000 Subject: [PATCH 4/4] use URLs for linking to comments --- ext/comment/theme.php | 2 +- lib/shimmie.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/comment/theme.php b/ext/comment/theme.php index 0b644390..51d7092a 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -203,7 +203,7 @@ class CommentListTheme extends Themelet { $hash = md5(strtolower($comment->owner_email)); $h_avatar = "
    "; } - $h_reply = " - Reply"; + $h_reply = " - Reply"; $h_ip = $user->can("view_ip") ? "
    ".show_ip($comment->poster_ip, "Comment posted {$comment->posted}") : ""; $h_del = $user->can("delete_comment") ? ' -