aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-02-09 11:20:46 +0000
committerMario <mario@mariovavti.com>2024-02-09 11:20:46 +0000
commit067a66b9278e3c8ff2c624f38f2817715eb8a316 (patch)
tree61ef1bf5cec4c5840df78483819b246767f349b1 /include
parent096fad5e8c71aea99d469b844d99fe9c9d58bc77 (diff)
downloadvolse-hubzilla-067a66b9278e3c8ff2c624f38f2817715eb8a316.tar.gz
volse-hubzilla-067a66b9278e3c8ff2c624f38f2817715eb8a316.tar.bz2
volse-hubzilla-067a66b9278e3c8ff2c624f38f2817715eb8a316.zip
fix some whitespace issues after recent changes
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php18
-rw-r--r--include/html2bbcode.php18
2 files changed, 20 insertions, 16 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index fb10ceb4a..a1e56b15f 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1384,32 +1384,32 @@ function bbcode($Text, $options = []) {
// 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);
+ $Text = str_replace(["</h1>\n\n", "</h1>\n"], '</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);
+ $Text = str_replace(["</h2>\n\n", "</h2>\n"], '</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);
+ $Text = str_replace(["</h3>\n\n", "</h3>\n"], '</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);
+ $Text = str_replace(["</h4>\n\n", "</h4>\n"], '</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);
+ $Text = str_replace(["</h5>\n\n", "</h5>\n"], '</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);
+ $Text = str_replace(["</h6>\n\n", "</h6>\n"], '</h6>', $Text);
}
// Check for table of content without params
@@ -1726,10 +1726,10 @@ function bbcode($Text, $options = []) {
// We'll emulate it.
$Text = str_replace("\r\n", "\n", $Text);
- $Text = str_replace(array("\r", "\n"), array('<br />', '<br />'), $Text);
+ $Text = str_replace(["\r", "\n"], '<br />', $Text);
- if ($preserve_nl)
- $Text = str_replace(array("\n", "\r"), array('', ''), $Text);
+// if ($preserve_nl)
+// $Text = str_replace(array("\n", "\r"), array('', ''), $Text);
call_hooks('bbcode', $Text);
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index c00df8f23..e97748a59 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -221,12 +221,12 @@ function html2bbcode($message)
node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
node2bbcode($doc, 'td', array(), "[td]", "[/td]");
- node2bbcode($doc, 'h1', array(), "\n\n[h1]", "[/h1]\n");
- node2bbcode($doc, 'h2', array(), "\n\n[h2]", "[/h2]\n");
- node2bbcode($doc, 'h3', array(), "\n\n[h3]", "[/h3]\n");
- node2bbcode($doc, 'h4', array(), "\n\n[h4]", "[/h4]\n");
- node2bbcode($doc, 'h5', array(), "\n\n[h5]", "[/h5]\n");
- node2bbcode($doc, 'h6', array(), "\n\n[h6]", "[/h6]\n");
+ node2bbcode($doc, 'h1', array(), "[h1]", "[/h1]");
+ node2bbcode($doc, 'h2', array(), "[h2]", "[/h2]");
+ node2bbcode($doc, 'h3', array(), "[h3]", "[/h3]");
+ node2bbcode($doc, 'h4', array(), "[h4]", "[/h4]");
+ node2bbcode($doc, 'h5', array(), "[h5]", "[/h5]");
+ node2bbcode($doc, 'h6', array(), "[h6]", "[/h6]");
node2bbcode($doc, 'img', array('src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'), '[img=$2x$3]$1', '[/img]');
node2bbcode($doc, 'img', array('src'=>'/(.+)/', 'alt'=>'/(.+)/'), '[img=$1]$2', '[/img]');
@@ -279,6 +279,8 @@ function html2bbcode($message)
$oldmessage = $message;
$message = str_replace(array(
"[/size]\n\n",
+ "\n[br]",
+ "[br]\n",
"\n[hr]",
"[hr]\n",
"\n[list",
@@ -289,6 +291,8 @@ function html2bbcode($message)
"\n[*]"),
array(
"[/size]\n",
+ "[br]",
+ "[br]",
"[hr]",
"[hr]",
"[list",
@@ -304,7 +308,7 @@ function html2bbcode($message)
array('[b]', '[/b]', '[i]', '[/i]'), $message);
// Restore linebreaks from temp tag
- $message = preg_replace('/\[br\]\s{1}|\[br\]/', "\n", $message);
+ $message = preg_replace('/\[br\]\s?/', "\n", $message);
// Handling Yahoo style of mails
// $message = str_replace('[hr][b]From:[/b]', '[quote][b]From:[/b]', $message);