Module: BBCode, Escaping Brackets (code included)
Posted by optimal
|
Re: Module: BBCode, Escaping Brackets (code included) April 23, 2008 04:09PM |
Registered: 18 years ago Posts: 57 |
Dutch, that makes sense! You're in good company for coders, there's a lot of talent in the Netherlands like Van Rossum!! I hope you're having a good time in America, the MySQL conference looked good!
When I get some spare time I'll definitely write a module or two for Phorum, I think the project is awesome in many ways, Kudos to you all!
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
When I get some spare time I'll definitely write a module or two for Phorum, I think the project is awesome in many ways, Kudos to you all!
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
|
Re: Module: BBCode, Escaping Brackets (code included) April 23, 2008 04:20PM |
Admin Registered: 22 years ago Posts: 8,532 |
For a company as small as the Netherlands, we have a lot of OSS coders around indeed!
And I guess the Netherlands has the most Phorum coders per head of the population too ;-)
@brianlmoon: insert random Dutch country size bashing quote here.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
And I guess the Netherlands has the most Phorum coders per head of the population too ;-)
@brianlmoon: insert random Dutch country size bashing quote here.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: BBCode, Escaping Brackets (code included) April 26, 2008 12:31PM |
Registered: 18 years ago Posts: 57 |
Hey fella, totally forgot to send you my DCode (BBCode) parser last week like I said! Apparently I can't attach, so I've uploaded a zip, and a demo on my dev site:
[dev.oopstudios.com]
[dev.oopstudios.com]
[dev.oopstudios.com]
My method is pretty different to "the normal" technique as it creates paragraphing rather than lots of <br />'s, you can see this as a good thing or a bad thing depending on how you like your HTML!
Hope you find it handy to some level!
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
[dev.oopstudios.com]
[dev.oopstudios.com]
[dev.oopstudios.com]
My method is pretty different to "the normal" technique as it creates paragraphing rather than lots of <br />'s, you can see this as a good thing or a bad thing depending on how you like your HTML!
Hope you find it handy to some level!
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
|
Re: Module: BBCode, Escaping Brackets (code included) April 26, 2008 06:59PM |
Admin Registered: 22 years ago Posts: 8,532 |
Cool code, but it looks a lot like what we used to do with the previous BBcode module: use regular expressions to get things working. It worked well for a while, but it got us into trouble with wrongly nested tags and supporting nested tags like [quote] and [list]. It also doesn't help in fixing the (X)HTML that is produced, meaning that [b][i]....[/b][/i] would not be seen as [b][i]....[/i][/b]. Not a big problem for basic HTML, but it introduced troubles for the ones that run in very strict XHTML XML environments. That was the main reason for starting a new parser altogether.
I see no problem in using <br/>'s BTW. We use them too. Parsing a text in real paragraphs could be tedious. and could result in effects that the user does not suspect. The user adds breaks to the message body and the closest thing relating to that is a <br/> anyway.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
I see no problem in using <br/>'s BTW. We use them too. Parsing a text in real paragraphs could be tedious. and could result in effects that the user does not suspect. The user adds breaks to the message body and the closest thing relating to that is a <br/> anyway.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: BBCode, Escaping Brackets (code included) April 26, 2008 07:35PM |
Registered: 18 years ago Posts: 57 |
Yeah, true on all points!
With what you've said about bad nesting ([B][I]...[/B][/I]), I think I may have to look into that a bit more, i'm not sure that the situation has cropped up for me yet!
Do you have a stance on pre parsing? That is, modifying the BBCode, then rendering the (X)HTML? Eg:
A user types:
it is preparsed into:
(so that if the user edits it again, (s)he will see the modified BBCode)
then it is rendered into the usual (X)HTML:
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
With what you've said about bad nesting ([B][I]...[/B][/I]), I think I may have to look into that a bit more, i'm not sure that the situation has cropped up for me yet!
Do you have a stance on pre parsing? That is, modifying the BBCode, then rendering the (X)HTML? Eg:
A user types:
here's [B]some[/B] bad[/I] nesting
it is preparsed into:
here's [I][B]some[/B] bad[/I] nesting
(so that if the user edits it again, (s)he will see the modified BBCode)
then it is rendered into the usual (X)HTML:
here's <em><strong>some</strong> bad</em> nesting
If it moves, eat it. If it doesn't move, wait till it moves, then eat it
|
Re: Module: BBCode, Escaping Brackets (code included) April 26, 2008 09:33PM |
Admin Registered: 22 years ago Posts: 8,532 |
I have "fixing bbcode at post time" as an option that I want to build into the BBcode module. It's really easy from where the module is right now. The tokenizing return data can be turned back into a message with only a few lines of code. I guess that with this kind of preparsing and fixing you could get the message body to a level where search-and-replace-style regular expressions could work to format the final message. But you got to be sure that you have any broken BBcode out of the way first. Either by fixing or by escaping the wrong BBcode.
I looked into this direction for a little while, but after a lot of benchmarking and testing I came up with the current code. One extra thing that can be done with this code to make things faster, is cache the intermediate tokenized data. The tokenizing step is what consumes most time and caching that info would be really easy to do. This would provide more processing speed up than fixing the BBcode tags at post time. However, my findings were that the code is so fast already, that you probably would not notice any speed increases in building the page, unless you're running a really busy forum (and even then, other parts of the system would probably be the bottle neck here). Nonetheless, there's a big chance that I put it in the module at some point anyway, since to Phorum devs every microsecond counts.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
I looked into this direction for a little while, but after a lot of benchmarking and testing I came up with the current code. One extra thing that can be done with this code to make things faster, is cache the intermediate tokenized data. The tokenizing step is what consumes most time and caching that info would be really easy to do. This would provide more processing speed up than fixing the BBcode tags at post time. However, my findings were that the code is so fast already, that you probably would not notice any speed increases in building the page, unless you're running a really busy forum (and even then, other parts of the system would probably be the bottle neck here). Nonetheless, there's a big chance that I put it in the module at some point anyway, since to Phorum devs every microsecond counts.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Sorry, only registered users may post in this forum.
