diff options
author | zotlabs <mike@macgirvin.com> | 2016-12-30 02:36:24 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-12-30 02:36:24 -0800 |
commit | 693f7366a2f8f4e7c4686e5701ff182da848dbb5 (patch) | |
tree | e2af1ea9dcae9e70979d67684776e3ca42eae27f /include/bbcode.php | |
parent | e8a2ad43158bf94d55e64a23040c4a84a9414720 (diff) | |
parent | c9cbd2f4f6cb432c6558bd88d783b356f0311a09 (diff) | |
download | volse-hubzilla-693f7366a2f8f4e7c4686e5701ff182da848dbb5.tar.gz volse-hubzilla-693f7366a2f8f4e7c4686e5701ff182da848dbb5.tar.bz2 volse-hubzilla-693f7366a2f8f4e7c4686e5701ff182da848dbb5.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include/bbcode.php')
-rw-r--r-- | include/bbcode.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index f0cf861f3..00d22d26d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -511,6 +511,20 @@ function bb_code($match) { return '<code class="inline-code">' . trim($match[1]) . '</code>'; } +function bb_code_options($match) { + if(strpos($match[0], "<br />")) { + $class = ""; + } else { + $class = "inline-code"; + } + if(strpos($match[1], 'nowrap')) { + $style = "overflow-x: auto; white-space: pre;"; + } else { + $style = ""; + } + return '<code class="'. $class .'" style="'. $style .'">' . trim($match[2]) . '</code>'; +} + function bb_highlight($match) { $lang = ((in_array(strtolower($match[1]),['php','css','mysql','sql','abap','diff','html','perl','ruby', 'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','json','sh'])) @@ -933,6 +947,11 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); } + // Check for [code options] text + if (strpos($Text,'[code ') !== false) { + $Text = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism", 'bb_code_options', $Text); + } + // Check for [spoiler] text $endlessloop = 0; while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) { |