]> git.mxchange.org Git - friendica.git/commitdiff
Add conditional block output for BBCode tag [style]
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 18 Oct 2021 01:27:05 +0000 (21:27 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 18 Oct 2021 01:27:05 +0000 (21:27 -0400)
- Move new line conversion to <br> tags
- Update BBCode help page

doc/BBCode.md
doc/de/BBCode.md
src/Content/Text/BBCode.php

index 753bc69425bf669ee73b611604cd7cbb3ae60a25..d232256583de571d528a244b06e1b55bdc31cb67 100644 (file)
@@ -644,11 +644,17 @@ On Mastodon this field is used for the content warning.
   </td>
   <td>;-) :-O</td>
 </tr>
+<tr>
+  <td>Custom block styles<br>
+<br>
+[style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style]</td>
+  <td><div style="text-shadow: 0 0 4px #cc0000;;">You can change all the CSS properties of this block.</div></td>
+</tr>
 <tr>
   <td>Custom inline styles<br>
 <br>
 [style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style]</td>
-  <td><span style="text-shadow: 0 0 4px #cc0000;;">You can change all the CSS properties of this block.</span></td>
+  <td>You can change all <span style="text-shadow: 0 0 4px #cc0000;;">the CSS properties of this inline text.</span></td>
 </tr>
 <tr>
   <td>Custom class block<br>
index ded52cdb7848e502cfcabda88b3894f4ca9ad31e..7af0861a7acd5a9d8dfc51652049ea3ef6700922 100644 (file)
@@ -603,11 +603,17 @@ Dieses Feld wird von Mastodon f&uuml;r die Inhaltswarnung (content warning) verw
   </td>
   <td>;-) :-O</td>
 </tr>
+<tr>
+  <td>Benutzerdefinierte Block-Styles<br>
+<br>
+[style=text-shadow: 0 0 4px #CC0000;]Du kannst alle CSS-Eigenschaften eines Blocks &auml;ndern-[/style]</td>
+  <td><div style="text-shadow: 0 0 4px #cc0000;;">Du kannst alle CSS-Eigenschaften eines Blocks &auml;ndern.</div></td>
+</tr>
 <tr>
   <td>Benutzerdefinierte Inline-Styles<br>
 <br>
 [style=text-shadow: 0 0 4px #CC0000;]Du kannst alle CSS-Eigenschaften eines Blocks &auml;ndern-[/style]</td>
-  <td><span style="text-shadow: 0 0 4px #cc0000;;">Du kannst alle CSS-Eigenschaften eines Blocks &auml;ndern-</span></td>
+  <td>Du kannst alle <span style="text-shadow: 0 0 4px #cc0000;;">CSS-Eigenschaften dieses Inline-Textes &auml;ndern-</span></td>
 </tr>
 <tr>
   <td>Benutzerdefinierte CSS Klassen<br>
index 7328328e23fb6785166445a5b56536ca57d0a72d..76bb9bb3f82c014e5b538646901337eeb4d2cf94 100644 (file)
@@ -1560,9 +1560,6 @@ class BBCode
                                        $text = self::convertAttachment($text, $simple_html, $try_oembed, [], $uriid);
                                }
 
-                               // Add HTML new lines
-                               $text = str_replace("\n", '<br>', $text);
-
                                $nosmile = strpos($text, '[nosmile]') !== false;
                                $text = str_replace('[nosmile]', '', $text);
 
@@ -1645,11 +1642,16 @@ class BBCode
                                // Check for list text
                                $text = str_replace("[*]", "<li>", $text);
 
-                               // Check for style sheet commands
+                               // Check for block-level custom CSS
+                               $text = preg_replace('#(?<=^|\n)\[style=(.*?)](.*?)\[/style](?:\n|$)#ism', '<div style="$1">$2</div>', $text);
+
+                               // Check for inline custom CSS
                                $text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism", '<span style="$1">$2</span>', $text);
 
                                // Check for CSS classes
                                $text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism", '<span class="$1">$2</span>', $text);
+                               // Add HTML new lines
+                               $text = str_replace("\n", '<br>', $text);
 
                                // handle nested lists
                                $endlessloop = 0;