Hi, I've got my own forum software I've coded. When people don't close their tags in their posts (the [ i ] for example) it'll cause the rest of post - the signature and stuff - to be italicized also. So far my horrible solution I've come to is to just making a bunch of closing tags in the code which is an obviously poor way of dealing with it.
Do you guys have any idea how I could auto-close all tags?
Users not closing their tags on my forum...
Moderator: General Moderators
-
Vael Victus
- Forum Newbie
- Posts: 24
- Joined: Wed Jun 03, 2009 9:29 am
Re: Users not closing their tags on my forum...
The way I think most applications deal with it is just not do the conversion.
That is, a opening/closing tag pair only gets handled if both the opening and closing tags are in place.
In terms of the code, rather than replace [i] with a <span> it replaces [i]text[/i] with <span>text</span>.
That is, a opening/closing tag pair only gets handled if both the opening and closing tags are in place.
In terms of the code, rather than replace [i] with a <span> it replaces [i]text[/i] with <span>text</span>.
-
Vael Victus
- Forum Newbie
- Posts: 24
- Joined: Wed Jun 03, 2009 9:29 am
Re: Users not closing their tags on my forum...
Oh that sounds like it's going into regular expression turf...
Do you know of an efficient way to check for all tags to have a closure? That'd be even better on the user. I'm good at PHP but I can't think of an efficient way to do it. That was my second option.
Do you know of an efficient way to check for all tags to have a closure? That'd be even better on the user. I'm good at PHP but I can't think of an efficient way to do it. That was my second option.
Re: Users not closing their tags on my forum...
Count the number of opening tags; count the number of closing tags. You can use substr_count for that.
BBCode implementations are traditionally done with regular expressions. Pretty simple ones even. It's not like you'd be admitting defeat to use them
BBCode implementations are traditionally done with regular expressions. Pretty simple ones even. It's not like you'd be admitting defeat to use them
Re: Users not closing their tags on my forum...
It will pass on overlapping tags: <b> some <i> text </b> here</i> even though it makes no sense from the html point of view.tasairis wrote:Count the number of opening tags; count the number of closing tags. You can use substr_count for that.