aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 050ab2d29..775a91f9a 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -246,8 +246,8 @@ function bb_parse_element($match) {
$j = json_decode(base64url_decode($match[1]),true);
if ($j && local_channel()) {
- $text = sprintf( t('Install %s element: '), translate_design_element($j['type'])) . $j['pagetitle'];
- $o = EOL . '<a href="#" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . $text . '</a>' . EOL;
+ $text = sprintf( t('Install %1$s element %2$s'), translate_design_element($j['type']), $j['pagetitle']);
+ $o = EOL . '<button class="btn btn-primary" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . $text . '</button>' . EOL;
}
else {
$text = sprintf( t('This post contains an installable %s element, however you lack permissions to install it on this site.' ), translate_design_element($j['type'])) . $j['pagetitle'];
@@ -329,6 +329,8 @@ function bb_ShareAttributes($match) {
if(strpos($link,'/cards/'))
$type = t('card');
+ elseif(strpos($link,'/articles/'))
+ $type = t('article');
else
$type = t('post');
@@ -705,10 +707,12 @@ function parseIdentityAwareHTML($Text) {
return $Text;
}
- // BBcode 2 HTML was written by WAY2WEB.net
- // extended to work with Mistpark/Friendica/Redmatrix/Hubzilla - Mike Macgirvin
-function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) {
+function bbcode($Text, $options = []) {
+
+ $preserve_nl = ((array_key_exists('preserve_nl',$options)) ? $options['preserve_nl'] : false);
+ $tryoembed = ((array_key_exists('tryoembed',$options)) ? $options['tryoembed'] : true);
+ $cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false);
call_hooks('bbcode_filter', $Text);
@@ -937,27 +941,34 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
// Check for h1
if (strpos($Text,'[h1]') !== false) {
$Text = preg_replace("(\[h1\](.*?)\[\/h1\])ism",'<h1>$1</h1>',$Text);
+ $Text = str_replace('</h1><br />', '</h1>', $Text);
}
// Check for h2
if (strpos($Text,'[h2]') !== false) {
$Text = preg_replace("(\[h2\](.*?)\[\/h2\])ism",'<h2>$1</h2>',$Text);
+ $Text = str_replace('</h2><br />', '</h2>', $Text);
}
// Check for h3
if (strpos($Text,'[h3]') !== false) {
$Text = preg_replace("(\[h3\](.*?)\[\/h3\])ism",'<h3>$1</h3>',$Text);
+ $Text = str_replace('</h3><br />', '</h3>', $Text);
}
// Check for h4
if (strpos($Text,'[h4]') !== false) {
$Text = preg_replace("(\[h4\](.*?)\[\/h4\])ism",'<h4>$1</h4>',$Text);
+ $Text = str_replace('</h4><br />', '</h4>', $Text);
}
// Check for h5
if (strpos($Text,'[h5]') !== false) {
$Text = preg_replace("(\[h5\](.*?)\[\/h5\])ism",'<h5>$1</h5>',$Text);
+ $Text = str_replace('</h5><br />', '</h5>', $Text);
}
// Check for h6
if (strpos($Text,'[h6]') !== false) {
$Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'<h6>$1</h6>',$Text);
+ $Text = str_replace('</h6><br />', '</h6>', $Text);
}
+
// Check for table of content without params
while(strpos($Text,'[toc]') !== false) {
$toc_id = 'toc-' . random_string(10);