]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #10888 from MrPetovan/task/10887-bbcode-style-block
authorMichael Vogel <icarus@dabo.de>
Mon, 18 Oct 2021 18:19:53 +0000 (20:19 +0200)
committerGitHub <noreply@github.com>
Mon, 18 Oct 2021 18:19:53 +0000 (20:19 +0200)
Add conditional block output for BBCode tag [style]

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

diff --cc doc/BBCode.md
index 0404c381bec63200085393bb913d048163749230,d232256583de571d528a244b06e1b55bdc31cb67..dae630448f77dd6afd3e527ebfdcbb86952b8cd5
@@@ -648,6 -654,12 +654,6 @@@ On Mastodon this field is used for the 
    <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>
 -<br>
 -[class=custom]If the class exists, this block will have the custom class style applied.[/class]</td>
 -  <td><pre>&lt;span class="custom"&gt;If the class exists,<br> this block will have the custom class<br> style applied.&lt;/span&gt;</pre></td>
 -</tr>
  </table>
index 534ebcc546c9ec0900d5873013f74e1010b5d498,7af0861a7acd5a9d8dfc51652049ea3ef6700922..5949e67e18ed2e1d15839660999607f893f262f2
@@@ -607,7 -613,15 +613,7 @@@ Dieses Feld wird von Mastodon f&uuml;r 
    <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>
 -<br>
 -[class=custom]Wenn die vergebene Klasse in den CSS Anweisungen existiert, wird sie angewandt.[/class]</td>
 -  <td><pre>&lt;span class="custom"&gt;Wenn die<br>
 -vergebene Klasse in den CSS Anweisungen<br>
 -existiert,wird sie angewandt.&lt;/span&gt;</pre></td>
 -</tr>
  </table>
  
index 696cc7d8c50de16c71978844d549c97ec092e4e9,76bb9bb3f82c014e5b538646901337eeb4d2cf94..da95c3d67338204aea087cb1f9fef0e9f02f277b
@@@ -1645,15 -1642,16 +1642,20 @@@ class BBCod
                                // 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);
  
 +                              // Mastodon Emoji (internal tag, do not document for users)
 +                              $text = preg_replace("(\[emoji=(.*?)](.*?)\[/emoji])ism", '<span class="mastodon emoji"><img src="$1" alt="$2" title="$2"/></span>', $text);
 +
                                // Check for CSS classes
 +                              // @deprecated since 2021.12, left for backward-compatibility reasons
                                $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;