adding string stripping for p- properties

I'm not really happy with this code: this sort of thing should be
abstracted by the HTML/XML library.

Kartik has suggested we switch to BeautifulSoup. it was a bit hacky last
time I looked, but if it reduces this kind of thing, I'd be in favour.