milesj / decoda

A lightweight lexical string parser for BBCode styled markup.
MIT License
196 stars 52 forks source link

Close tags not in order as Open tag causes Remove other things #4

Closed ghost closed 12 years ago

ghost commented 13 years ago

[spoiler][COLOR="DarkSlateBlue"][CENTER][SIZE="4"][B]TEXT HERE[/B][/SIZE][/COLOR][/CENTER][/spoiler]

If we take a loot above, [/CENTER] close tag is not in order, so the parser removes [spoiler], and spoiler does not show.

Note : Sorry bout my english

ghost commented 13 years ago

Sorry, i've added some code in BlockFilter.php

    'center' => array(
        'template' => 'center',
        'type' => self::TYPE_BLOCK,
        'allowed' => self::TYPE_BOTH
    ),

center.php <div align="center"><?=$content;?></center>

ghost commented 13 years ago

Simple example : [B][I]TEST[/B][/I]

Just produce : TEST

Instead of : TEST <==VBulltein

milesj commented 12 years ago

Decoda doesn't fix incorrect nested tags, it removes them, that is by design.

ghost commented 12 years ago

Hi, It's great to have you reply. :)

I found on the php decoda features, one of them said that : "Fixes incorrectly nested tags"

Do i miss understand?

I use php decoda on my first forum, hope it's gonna be something big in 12 months. It's almost finished, but still in progress on bbcode and rte. Wish php decoda on future has 2 features :

Example : $code->isAllTagsOK(); // returns true or false

So we can tell user if he has written incorrect nested tags instead of removing them and makes him confuse and thinking my application has bug/error.

Thank you

milesj commented 12 years ago

Well technically it is fixing the incorrectly nested tags by removing them, heh. I should probably clarify it more.

It was a conscious decision to remove the incorrect nested tags instead of trying to correct it, as that logic is quite heavy. If the user nests incorrectly, they should go back and fix it, shouldn't be reliant on system to try and catch every failure.

However, it has been a while since I worked on Decoda, so I will look a bit more to see exactly what the code is doing.

milesj commented 12 years ago

After looking at the code, I will not be changing it to fix the incorrect nesting. However, I did add a getErrors() method which will return all the problems. This can be found in 3.1: https://github.com/milesj/php-decoda

The types of errors are: 1 (nesting) - Incorrectly nested tags 2 (closing) - Unclosed tags 3 (scope) - Placing block elements within inline elements

ghost commented 12 years ago

Thanks a lot!

Now with [center] tag too. Thanks again.

Hope it will get more features and someday could fix the incorrect nesting.

Regards, birkoffkeren