From a769efae383ecfdffc86d754d9eca7537101fa48 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 14 Oct 2018 07:43:44 -0400 Subject: [PATCH 1/2] Remove whitespace clearing around code tags - Normalize inline code blocks to --- src/Content/Text/BBCode.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 66f4190b28..c903ee6945 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1265,9 +1265,6 @@ class BBCode extends BaseObject $text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "[share$1]$2[/share]", $text); $text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism", "[quote$1]$2[/quote]", $text); - $text = preg_replace("/\n\[code\]/ism", "[code]", $text); - $text = preg_replace("/\[\/code\]\n/ism", "[/code]", $text); - // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems if (!$try_oembed) { $text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "\n[share$1$2]$3[/share]", $text); @@ -1717,18 +1714,6 @@ class BBCode extends BaseObject $text = Smilies::replace($text, false, true); } - // Replace inline code blocks - $text = preg_replace_callback("|(?!]*>)([^<]*)(?!]*>)|ism", - function ($match) use ($simple_html) { - $return = '' . $match[1] . ''; - // Use for Diaspora inline code blocks - if ($simple_html === 3) { - $return = '' . $match[1] . ''; - } - return $return; - } - , $text); - // Unhide all [noparse] contained bbtags unspacefying them // and triming the [noparse] tag. From f7c020af04426483f875b742599defab10926c7c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 14 Oct 2018 07:44:07 -0400 Subject: [PATCH 2/2] Add HTML result boxes to mod/babel --- mod/babel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mod/babel.php b/mod/babel.php index e5ae96be70..65287b9f2b 100644 --- a/mod/babel.php +++ b/mod/babel.php @@ -114,6 +114,17 @@ function babel_content() 'content' => visible_whitespace($bbcode) ]; + $html2 = Text\BBCode::convert($bbcode); + $results[] = [ + 'title' => L10n::t('HTML::toBBCode => BBCode::convert'), + 'content' => $html2 + ]; + + $results[] = [ + 'title' => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'), + 'content' => htmlspecialchars($html2) + ]; + $markdown = Text\HTML::toMarkdown($html); $results[] = [ 'title' => L10n::t('HTML::toMarkdown'),