New BBCode parser?
I was working on SnowCMS (Yeah, I am back again
), and I started to become super annoyed that the same BBCode tags cannot be nested within one another. So in just a couple minutes, I tried to figure out a way to get those to work. I tried doing something like this before, but for the life of me, I couldn’t get it!
Not to long ago I began pondering how I could approach this problem, and how other systems do it. I then thought, XML! I remembered that in PHP using XML Parser it parses the XML file into levels with by tags, and that is how I am approaching it
I already have a very very very (Did I say very?) rough prototype, only ~32 lines of code, the function parses this string:
[b]Hello there![/b] [i]Why? [color=red]CAUSE![/color][/i]
Into:
Array
(
[1] => [b]
[2] => Hello there!
[3] => [/b]
[4] =>
[5] => [i]
[6] => Why?
[7] => [color=red]
[8] => CAUSE!
[9] => [/color]
[11] => [/i]
)
Right now it isn’t parsed very pretty like
But for the time being, it works for the most part! I can’t wait to dig deeper into this idea tomorrow… Seeya for now! (It is 12:15AM at the time I am posting this, Lol)