]> Raphaël G. Git Repositories - bbcode/commitdiff
Switch to single|root|multi type
authorRaphaël Gertz <git@rapsys.eu>
Tue, 8 Jan 2019 17:59:32 +0000 (18:59 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 8 Jan 2019 17:59:32 +0000 (18:59 +0100)
Adapt to new data structure

tests/002.phpt
tests/003.phpt

index a1359a43f431c2f32c4e7b55fc8e9a36a986c4cf..b9d101a6d84d299581a2f417a39e232eb14a9c85 100644 (file)
@@ -6,33 +6,35 @@ Check for bbcode functions
 <?php
 $obj = new bbcode(
        [
+               'img' => [
+               ],
                '' => [
                        'type' => BBCODE::TYPE_ROOT,
-                       'childs' => ['ul','url','img','b','i']
+                       'child' => ['ul','url','img','b','i']
                ],
                'i' => [
-                       'type' => BBCODE::TYPE_NOARG
+                       'type' => BBCODE::TYPE_MULTI
                        //TODO: by default open tag = <KEY> and close tag = </KEY>
                ],
                'b' => [
-                       'type' => BBCODE::TYPE_NOARG
+                       'type' => BBCODE::TYPE_MULTI
                ],
                'ul' => [
-                       'type' => BBCODE::TYPE_NOARG,
-                       'childs' => [ 'li' ]
+                       'type' => BBCODE::TYPE_MULTI,
+                       'child' => ['li']
                ],
                'li' => [
-                       'type' => BBCODE::TYPE_NOARG,
-                       'parent' => 'ul',
-                       'childs' => ['url','img','b','i']
+                       'type' => BBCODE::TYPE_MULTI,
+                       'parent' => ['ul'],
+                       'child' => ['url','img','b','i']
                ],
                'url' => [
-                       'type' => BBCODE::TYPE_OPTARG,
-                       'open_tag' => '<a href="{PARAM}">',
-                       'close_tag' => '</a>',
-                       'default_arg' => '{CONTENT}',
-                       'parent' => [ '', 'li', 'b', 'i' ]
-               ]
+                       'type' => BBCODE::TYPE_MULTI,
+                       'parent' => ['','li','b','i'],
+                       'open' => '<a%s>',
+                       'close' => '</a>',
+                       'arg' => 'href'
+               ],
        ],
        [
                ':)' => '<img src="smiley.gif" alt=":)" />',
index 0e30488fc9aa167095e0b15ebf08ee3311bb73f9..36c39318bd512a37c2abf27781947639b58dd66b 100644 (file)
@@ -8,30 +8,30 @@ $obj = new bbcode(
        [
                '' => [
                        'type' => BBCODE::TYPE_ROOT,
-                       'childs' => ['ul','url','img','b','i']
+                       'child' => ['ul','url','img','b','i']
                ],
                'i' => [
-                       'type' => BBCODE::TYPE_NOARG
+                       'type' => BBCODE::TYPE_MULTI
                        //TODO: by default open tag = <KEY> and close tag = </KEY>
                ],
                'b' => [
-                       'type' => BBCODE::TYPE_NOARG
+                       'type' => BBCODE::TYPE_MULTI
                ],
                'ul' => [
-                       'type' => BBCODE::TYPE_NOARG,
-                       'childs' => [ 'li' ]
+                       'type' => BBCODE::TYPE_MULTI,
+                       'child' => [ 'li' ]
                ],
                'li' => [
-                       'type' => BBCODE::TYPE_NOARG,
+                       'type' => BBCODE::TYPE_MULTI,
                        'parent' => 'ul',
-                       'childs' => ['url','img','b','i']
+                       'child' => ['url','img','b','i']
                ],
                'url' => [
-                       'type' => BBCODE::TYPE_OPTARG,
-                       'open_tag' => '<a href="{PARAM}">',
-                       'close_tag' => '</a>',
-                       'default_arg' => '{CONTENT}',
-                       'parent' => [ '', 'li', 'b', 'i' ]
+                       'type' => BBCODE::TYPE_MULTI,
+                       'parent' => [ '', 'li', 'b', 'i', null, 'toto', 0, 42 ],
+                       'open' => '<a href="{PARAM}">',
+                       'close' => '</a>',
+                       'default' => '{CONTENT}'
                ]
        ],
        [
@@ -40,7 +40,7 @@ $obj = new bbcode(
                ':D' => '<img src="happy.gif" alt=":D" />',
                ':p' => '<img src="tong.gif" alt=":p" />',
                ':|' => '<img src="special.gif" alt=":|" />',
-               ':6:' => '<img src="six.gif" alt=":6:" />'
+               ':6:' => '<img src="six.gif" alt=":6:" />',
        ],
        BBCODE::REMOVE_EMPTY
 );