quote:
Originally posted by WDZ
Why should the parser be expected to fix mistakes like that? It's possible to produce invalid HTML with just about any BBCode parser that doesn't use a state machine or some other complicated and slow solution like that.
What? calling a state-machine slower than a string replace
? With string replacing, you're already looping through the string several times, why would doing it once but slightly different be any slower?
Actually, with algorithms like
Aho-Corasick, you could probably suffice with looping through it just once and doing all the BBCode replaces properly with a stack and all.
The fact that implementing a state machine in PHP is slower than using the built-in regexp or string replacing functions doesn't mean it's slower by definition
In theory (and probably also in practice, if you'd write a PHP module for it) a state machine would probably be one of the fastest and most elegant way to implement BBCode parsing
(Sorry mate, just couldn't resist
)