Function to truncate HTML text without removing the tags