I have created a very simple markup parser in php. However, it currently uses str_replace to switch between markup and html. How can I make a "code" box of sorts (will eventually use GeSHI) that has the contents untouched?
Right now, the following markup: [code][b]Some bold text[/b][/code]
winds up parsing as the code box with <b>Some bold text</b>
.
I need some advice, which option is best?
- Have it check each word individually, and if it is not inside a [code] box it should parse
- Leave it as is, let users be unable to post markup inside of [code].
- Create another type of code box specifically for HTML markup, have [code] autorevert any < or > to [ and ].
Is there maybe even another option? This is a bit tougher than I thought it would be...
EDIT: Is it even worth adding a code box type thing to this parser? I mean, I see how it could be useful, but it is a rather large amount of effort for a small result.