aboutsummaryrefslogtreecommitdiffstats
path: root/include/html2bbcode.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-02-06 18:39:51 +0100
committerHarald Eilertsen <haraldei@anduin.net>2024-02-06 18:39:51 +0100
commitec19ee9d82a9d06e5b86fcb58329767226b0676f (patch)
tree32cc72b0821b2dafae4cb16dde394b58d0cd590c /include/html2bbcode.php
parent983f063d33efbf2c6fb43c3aa12562b464b2cb9c (diff)
downloadvolse-hubzilla-ec19ee9d82a9d06e5b86fcb58329767226b0676f.tar.gz
volse-hubzilla-ec19ee9d82a9d06e5b86fcb58329767226b0676f.tar.bz2
volse-hubzilla-ec19ee9d82a9d06e5b86fcb58329767226b0676f.zip
Fix convert code blocs from markdown/html to bbcode
Diffstat (limited to 'include/html2bbcode.php')
-rw-r--r--include/html2bbcode.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 5cb153a77..f75a3e428 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -127,8 +127,15 @@ function html2bbcode($message)
$xpath = new DomXPath($doc);
$list = $xpath->query("//pre");
- foreach ($list as $node)
- $node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
+ foreach ($list as $node) {
+ if ($node->hasChildNodes()) {
+ foreach ($node->childNodes as $child) {
+ $child->nodeValue = str_replace("\n", "\r", $child->nodeValue);
+ }
+ } else {
+ $node->nodeValue = str_replace("\n", "\r", $node->nodeValue);
+ }
+ }
$message = $doc->saveHTML();
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br />", " ", ""), $message);