fixed regex in truncate function

The old version didn't match the h1, h2, ... elements correctly and
caused a wrong </h> closing tag.