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

Comments

mysurface said…
Ya, sed it a good handy tool, I even use it to modify huge sql dump file last time when I upgrade LBE post's style.

You can edit the file in place, if you are really sure. And it is more clean than using cat.

Check out this,
http://lne.blogdns.com/lbe/archives/129/search-and-replace/

Popular posts from this blog

Tee'ing Python subprocess.Popen output

Consolidated community site infrastructure on Plone

Adding simple popup to Plone frontpage