Monday, January 01, 2007

HOWTO: Adding Non-Strict HTML into Blogger Widget Template XML

I have been trying to insert some javascript buttons into the Posts widget of the new Blogger engine. There are no predefined widgets provided by Blogger for this purpose, so, I opened the template's HTML to insert it. However, the task that I thought gonna be easy became a frustrating task because the engine requires strict XHTML coding in the template thus making everything a nightmare to pass the syntax checker.

Struggling to insert the code, I discovered that the engine will parse any &lt; and &gt; entries into < and > of the generated code. So , I fire up gedit, paste the code, and do a search and replace for & < and >, replacing them with &amp; &lt; &gt; and pasted the new code into the template. The result is -> Success!! -> look at the stumbleupon button below :)

Linux and BSD users can do this quickly on a text file by using sed.
cat file|sed s/'\&'/'\&amp;'/g|sed s/'<'/'\&lt;'/g|sed s/'>'/'\&gt;'/g
Post a Comment