in reply to CGI Typein box for pseudo-HTML - is there a module?

On the client-side, there are various javascript DOM APIs for dealing with HTML fragments, or you can let the browser do it implicitly (it has a very fast HTML parser :-).

A trick I've done in the past to "balance" unbalanced HTML-source is to:

  1. create a placeholder div with document.createElement (don't bother to attach it to the document),
  2. assign the "unbalanced" text to the innerHTML property of the new DIV, and
  3. retrieve the innerHTML back from the div.

If that doesn't work for you, you might try the Range.cloneContents method (the standard says this does balance "unbalanced" tags for you).

Either of those can be done in (for example) a submit handler.

On the perl side you can use something like HTML::PullParser, which gives you a lot of control over what you wish to ignore.

-David

  • Comment on Re: CGI Typein box for pseudo-HTML - is there a module?