El Dorado

A full-stack community web application written in Ruby/Rails
Tue, 27 May 2008, 11:55am Updates for bbcodeizer »
irkenInvader
Member
Zim
Registered: May, 2008
Last visit: Wed, 04 Jun 2008
Posts: 85

Hi Trevor,

First, I'm not sure if this is the 'forum' that you want to discuss code changes/ideas/updates. If not, let me know what would be more appropriate. google group? email?

Second, I spent a lot of time (too much time - I'm obsessed!) over the long weekend thinking about how to clean up bbcodeizer so it works with simple_format better.

The problem, as I saw it, was that bbcodeizer outputs posts (any strings, really) with lots of newlines strewn about that shouldn't have been there. The three most obvious examples were in the [quote], [code], and my new [list] blocks. When rails handed the bbcodeized post over to simple_format, it would just append <br /> to any newlines, not replace the newlines. This would result (especially in those blocks) in extra double-spaces.

So, I've learned way more about strings, regex objects, matchData objects, and working with all three together in Ruby than I ever wanted! The end result is some significant changes to the way that bbcodeizer handles those blocks so as to clean up any extraneous newlines entered by a poster before handing the post over to simple_format. This way, bbcodeizer cleans up it's own generated HTML and lets simple_format do what it should without accidentally adding needless double-spaces.

I also implemented your idea about how to implement the list item (<li>) tags. You'll see when I get the patch done. I'll also upload my changes to the bbcode docs that encompass all the changes I made.

On a side note, I also added a literal tag to bbcodeizer so that bbcode tags could be referenced in posts without being parsed by bbcodeizer. In other words, you could write [code] and bbcodeizer translates that into &#91code&#93, the XHTML and HTML4 literals for open-square-bracket and close-square-bracket.

I'm going to fork your el-dorado github project, make the changes, check them in, and then attempt to send you a pull request. We'll see how that all works out this evening when I get home and can access github correctly (my work's network firewall doesn't allow traffic on the git:// ports)


Zim wrote:

Invader’s blood marches through my veins like giant, radioactive rubber pants! The pants command me! Do not ignore my veins!

Offline