truncate html text and keep tag safe