diff --git a/doc/BBCode.md b/doc/BBCode.md
index 0404c381b..dae630448 100644
--- a/doc/BBCode.md
+++ b/doc/BBCode.md
@@ -644,10 +644,16 @@ On Mastodon this field is used for the content warning.
;-) :-O |
+
+ Custom block styles
+
+[style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style] |
+ You can change all the CSS properties of this block. |
+
Custom inline styles
[style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style] |
- You can change all the CSS properties of this block. |
+ You can change all the CSS properties of this inline text. |
diff --git a/doc/de/BBCode.md b/doc/de/BBCode.md
index 534ebcc54..5949e67e1 100644
--- a/doc/de/BBCode.md
+++ b/doc/de/BBCode.md
@@ -603,11 +603,17 @@ Dieses Feld wird von Mastodon für die Inhaltswarnung (content warning) verw
;-) :-O |
+
+ Benutzerdefinierte Block-Styles
+
+[style=text-shadow: 0 0 4px #CC0000;]Du kannst alle CSS-Eigenschaften eines Blocks ändern-[/style] |
+ Du kannst alle CSS-Eigenschaften eines Blocks ändern. |
+
Benutzerdefinierte Inline-Styles
[style=text-shadow: 0 0 4px #CC0000;]Du kannst alle CSS-Eigenschaften eines Blocks ändern-[/style] |
- Du kannst alle CSS-Eigenschaften eines Blocks ändern- |
+ Du kannst alle CSS-Eigenschaften dieses Inline-Textes ändern- |
diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index 696cc7d8c..da95c3d67 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -1560,9 +1560,6 @@ class BBCode
$text = self::convertAttachment($text, $simple_html, $try_oembed, [], $uriid);
}
- // Add HTML new lines
- $text = str_replace("\n", '
', $text);
-
$nosmile = strpos($text, '[nosmile]') !== false;
$text = str_replace('[nosmile]', '', $text);
@@ -1645,7 +1642,10 @@ class BBCode
// Check for list text
$text = str_replace("[*]", "", $text);
- // Check for style sheet commands
+ // Check for block-level custom CSS
+ $text = preg_replace('#(?<=^|\n)\[style=(.*?)](.*?)\[/style](?:\n|$)#ism', '$2
', $text);
+
+ // Check for inline custom CSS
$text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism", '$2', $text);
// Mastodon Emoji (internal tag, do not document for users)
@@ -1654,6 +1654,8 @@ class BBCode
// Check for CSS classes
// @deprecated since 2021.12, left for backward-compatibility reasons
$text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism", '$2', $text);
+ // Add HTML new lines
+ $text = str_replace("\n", '
', $text);
// handle nested lists
$endlessloop = 0;