hi. i have a few stuff to allow custom bbcode. the problem is that when text is typed directly, it's not inserted within paragraphs.

here is the challenge: i'd like to make some regexp that would insert anything that is typed with <p>tags</p>. nothing hard here however, this should be done ONLY if for the bits of texts that don't start with other custom bbcode tags.

is that clear?

if i type
blah blah blah hello hello
this should become:
Code:
<p>
blah blah blah hello hello
</p>
now if I type
blah blah [ highlight ]a highlighted paragraph[ /highlight ] blah blah
it should become:
Code:
<p>
blah blah 
</p>
<p class="highlight">
a highlighted paragraph
</p> 
<p>
blah blah
</p>
in other words, i should add something to code below (probably at the end of the list) that checks that if a bit of the text string starts with a custom bbcode, or another one, or another one (etc.) it should nothing, otherwise add <p> tags.

PHP Code:
$text=preg_replace('#\[php\](.+?)\[/php\]#msi''<p class="php">\\1</p>'$text);
$text=preg_replace('#\[highlight\](.+?)\[/highlight\]#msi''<p class="highlight">\\1</p>'$text);
$text=preg_replace('#\[offtopic\](.+?)\[/offtopic\]#msi''<p class="offtopic">\\1</p>'$text);  
$text=preg_replace('#\[edit\](.+?)\[/edit\]#msi''<p class="edit">\\1</p>'$text);   
$text=preg_replace('#\[quote\](.+?)\[/quote\]#msi''<p class="quote">\\1</p>'$text); 
i hope i was clear. i would be incredibly grateful to anyone helping me with that.