milesj / decoda

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

Wrong u tag #113

Open general03 opened 8 years ago

general03 commented 8 years ago

When I want to put the string [U_] in bold, all my page are boken. It's because [U_] is recognize like u tag but I only want display the string !

Do you have an escape method for this ?

Regards

milesj commented 8 years ago

Are you talking about [u]? I'm a bit confused.

general03 commented 8 years ago

Yes, I want to display the string [U_] but it recognize like [u]

milesj commented 8 years ago

Nope, sorry, there's no way to not parse a tag if it's been registered.

general03 commented 8 years ago

I think I didn't explain well my issue. I have this text ... blablabla blabla [b][U_][/b] blabla bla blablabla... and I want to have this result ...blablabla blabla [U_] blabla bla blablabla...

So [U_] it's not a tag it's text for me but decoda recognize it like u tag

milesj commented 8 years ago

Yeah, it's weird since _ isn't recognized during parsing: https://github.com/milesj/decoda/blob/master/src/Decoda/Decoda.php#L1020

Perhaps it's getting confused about attributes.

general03 commented 8 years ago

Can't you reproduce this issue ?

milesj commented 8 years ago

I can reproduce but there's no way to solve this exact use case. It would completely break the parser as this is a valid tag, regardless of the _ and uppercase.

However, I decided to add support for literal tags: https://github.com/milesj/decoda/commit/6761bede186b23c5eb912171ab8c199b29e31ad9 Which will allow for tags to be rendered without transforming them, by supplying double brackets. For example, [[u]] will be rendered as [u] instead of <u>.