WackoWiki: Multi line actions and formatters

https://wackowiki.org/doc     Version: 15 (18.10.2024 03:39)

Multi line actions and formatters

The main goal is that the user can move each argument on a own line for better readability.

{{movie
  title="A Civil Action"
  image="a_civil_action_poster.jpg"
  author="Jonathan Harr"
  country="United States"
  language="English"
  published="1998-12-25"
  runtime="115 minutes"
  starring= ...
}}	

Add a short guide how to write your own content templates[link1].

methods syntax dynamic
Action {{name param... }} yes
Formatter %%(type) content%% no
These are the two favorite ways to expand the markup rules. Among other things, the use of these methods does not require a detailed analysis of the initial class of the Wacko formatter.



patch:
diff --git a/src/formatter/class/post_wacko.php b/src/formatter/class/post_wacko.php
index 0a7819f..702ee9e 100644
--- a/src/formatter/class/post_wacko.php
+++ b/src/formatter/class/post_wacko.php
@@ -66,7 +66,7 @@
             }
         }
         // actions
-        else if (preg_match('/^<!--action:begin-->\s*([^\n]+?)<!--action:end-->$/us', $thing, $matches))
+        else if (preg_match('/^<!--action:begin-->\s*(.*?)<!--action:end-->$/us', $thing, $matches))
         {
             // check for action parameters
             $sep = mb_strpos($matches[1], ' ');
diff --git a/src/formatter/class/wackoformatter.php b/src/formatter/class/wackoformatter.php
index 0313377..c074a18 100644
--- a/src/formatter/class/wackoformatter.php
+++ b/src/formatter/class/wackoformatter.php
@@ -274,7 +274,7 @@
                 : "\%\%.*?\%\%|") .
             "~([^ \t\n]+)|" .
             "\"\".*?\"\"|" .
-            "\{\{[^\n]*?\}\}|" .
+            "\{\{.*?\}\}|" .
             "<!--escaped-->.*?<!--escaped-->" .
             ")/usm";

@@ -349,7 +349,7 @@
             // check if a formatter has been specified
             $code = $matches[1];

-            if (preg_match('/^\(([^\n]+?)\)(.*)$/us', $code, $matches))
+            if (preg_match('/^\(\s*(.*?)\)(.*)$/us', $code, $matches))
             {
                 $code = $matches[2];

@@ -420,7 +420,7 @@
         else if (preg_match('/^\{\{(.*?)\}\}$/us', $thing, $matches))
         {
             // used in paragrafica, too
-            return '<!--escaped--><ignore><!--notypo--><!--action:begin-->' . $matches[1] . '<!--action:end--><!--/notypo--></ignore><!--escaped-->';
+            return '<!--escaped--><ignore><!--notypo--><!--action:begin-->' . str_replace("\n", ' ', $matches[1]) . '<!--action:end--><!--/notypo--></ignore><!--escaped-->';
         }

         // if we reach this point, it must have been an accident