veger / ruby-bbcode

Convert BBCode to HTML and check whether the BBCode is valid
http://rubygems.org/gems/ruby-bbcode
MIT License
28 stars 29 forks source link

[ul][li] is kind of a pain to deal with right now #2

Closed TheNotary closed 12 years ago

TheNotary commented 12 years ago

So these inputs won't parse well

[ul] [li]First Element[/li] [li]Second Element[/li] [li]Third Element[/li] [/ul]

And I think it should. The [ul] complains that it can't have
elements in it. Is this easy to fix?

veger commented 12 years ago

Thanks for reporting this issue.

Yes, it should work. I'll take a look at it soon.

veger commented 12 years ago

I am able to reproduce the problem: it is due to the line breaks in your example. I am working on a fix.

veger commented 12 years ago

I fixed your problem, I think. Could you let me know whether I understood your problem correctly and indeed fixed it?

TheNotary commented 12 years ago

Just tested it out, that's a pretty good fix. You might also consider making it remove the
unless there are consequtive spaces. IE

[ul] [li]First Element[/li] [li]Second Element[/li] [li]Third Element[/li] [/ul]

Would convert to the same output as

[ul][li]First Element[/li][li]Second Element[/li][li]Third Element[/li][/ul]

Yet

[ul] [li]First Element[/li]

[li]Second Element[/li]

[li]Third Element[/li] [/ul]

Would convert to something with those
tags in it. That's just a though though. Either way this is a good fix and I'm glad it worked out. Thanks for your work on the gem =)

veger commented 12 years ago

I was planning to keep the whitespace characters in, as the person that types the BB code intended it (or not... but still typed it). Automatically removing whitespace might 'upset' these persons. (I think) But feel free to fork the project and to modify it for your own purposes