• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

HTML validation

dejitaru

Banned
I'm writing a guestbook
How would I verify that all HTML tags have been closed?
Is there some PHP function that will do this automatically?
 
Originally posted by: Superwormy
http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=html+validator
Aren't you a riot.
I was looking for an algorithm. None of those had the source code available.
 
I was writing something similar to for posting news updates on my website. I considered using forum style tags like the ones we use here at Anandtech instead and then converting them to HTML. Then I would parse the input for <'s and >'s to make sure to replace those with HTML character codes. That way, any HTML that I or anyone types, would end up looking like &bla;table&bla2; instead of </table>. The HTML code that you enter is rendered useless because the < and > sign's are converted to HTML character codes.

EDIT: Fixed my link.
 
I want some HTML functionality, but I want to make certain all tags are closed so that they don't spill into other posts.
 
parse the input for anything matching /<([A-zA-z]+).*?>/ and then search for a corresponding /<\/$1>/ to close it. Make sure that the number of opening and closing brackets are the same.
 
Seems like a job for a stack. For every tag of a certain kind, push the stack, for every closing tag, pop back. If there are any stacks with something in them at the end, throw up an error.
 
Back
Top