milesj / decoda

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

Aliasing of attributes missing #31

Closed sckoop closed 11 years ago

sckoop commented 11 years ago

Hi Miles,

I've got one question. In the newest version of decoda. I miss the possibility to alias a attribute. Is there a specific reason why it is removed?

Kind regards Sean

milesj commented 11 years ago

All of the field names changed, check out FilterAbstract to see what they should be.

sckoop commented 11 years ago

Hi Miles,

checked it and think it was map attributes which seems not be working correctly.

For example you've got the following configuration for a url tag.

...
'attributes' => array(
    'target' => '/self|new/i'
 ),
'mapAttributes' => array(
    't' => 'target'
),
...

and the string looks as following: [url t="new"][/url] In the old style you could use the alias parameter and it the parser handled it like the target attribute. Now I would need to add the t value as well to the attributes to have this correctly handled. (Which make it obsolete to define it in the mapping)

Reason is that in line 1016 in decoda.php only the source is checked for the key without consideration of the mapping. Do you see it as possible to bring back this behaviour?

milesj commented 11 years ago

I think the problem is that this line should be $finalKey instead of $key. The code is pretty much the same thing as it was before.

https://github.com/milesj/php-decoda/blob/master/Decoda.php#L1016

sckoop commented 11 years ago

Tried it but then you get a problem with the url tag and the mapping of default to href. I thought about it to check in https://github.com/milesj/php-decoda/blob/master/Decoda.php#L1016 both attributes, but then you've got still the problem that the pattern is not correctly loaded.

milesj commented 11 years ago

Ok, check out the latest master commit. This should fix it.

It still uses mapAttributes.

sckoop commented 11 years ago

Thanks works fine :)