aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-05-30 16:12:48 +0200
committerMario Vavti <mario@mariovavti.com>2016-05-30 16:12:48 +0200
commitd1efb59fcdd3d5e78f3071c7a7a959c285782931 (patch)
tree578ce7aa90d404cad9c534cde984f6f767644743 /include
parentf2ebe41a509d6e7f332fdc4cb43d14d555375bdf (diff)
downloadvolse-hubzilla-d1efb59fcdd3d5e78f3071c7a7a959c285782931.tar.gz
volse-hubzilla-d1efb59fcdd3d5e78f3071c7a7a959c285782931.tar.bz2
volse-hubzilla-d1efb59fcdd3d5e78f3071c7a7a959c285782931.zip
render code bbcode inline if there are no linebreaks in the text.
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index f47dc6f2e..42741b392 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -477,9 +477,12 @@ function bb_observer($Text) {
return $Text;
}
-
-
-
+function bb_code($match) {
+ if(strpos($match[0], "<br />"))
+ return '<code>' . trim($match[1]) . '</code>';
+ else
+ return '<code class="inline-code">' . trim($match[1]) . '</code>';
+}
@@ -785,12 +788,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text);
}
- // Declare the format for [code] layout
- $CodeLayout = '<code>$1</code>';
-
// Check for [code] text
if (strpos($Text,'[code]') !== false) {
- $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $Text);
+ $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text);
}
// Check for [spoiler] text