Patching mnoGoSearch to generate valid XHTML

At work we use mnoGoSearch to handle our sitewide search engine needs. It’s a pretty powerful and flexible tool, but has a couple annoyances:

  1. The documentation is uneven at best.
  2. Out of the box, the app can’t generate valid XHTML.

The second one is what was annoying me today, because even after you clean up the example templates, it still insists on mucking up your code. mnoGoSearch seems to rewrite some of the <input> tags is displays, making the “value” attribute uppercase, and forcing a space after every attribute/value combo inside the tag. The latter is problematic because it treats the closing “/” in the <input> tag as an attribute, forcing a space after it. Both of these behaviors ruin my finely tuned XHTML 1.1 transitional-valid code.

So, in a fit of open-source excitement, I decided to patch the code myself. I’m definitely NOT a C programmer, but finding and patching the appropriate code was pretty straightforward. The culprit is the TemplateTag function in the file template.c, which I’ve modified to do the following:

  1. Write the “value” attribute as lowercase
  2. place the separating space before the attribute

These changes get it to play nice with XHTML, and shouldn’t affect the search engine’s ability to generate valid HTML.

Since I’m not versed in the ways of diff and patch, I’ll just upload the whole file. It gets interesting around line 335.

Patched template.c | Pretty coloriffic source generated by c++2html

Edit: That first version didn’t really work. This one does, though.