I trying to use “striptags” and “removetags:” but not quite working. Text is something like this:
bla, bla, bla <p style="margin-top: 10px; margin-right: 0px; ....
If i use striptags or removetags with truncatewords, template completely breaks down.
you should clean the string first then use truncate words.. you can use regular expression to clean tags if strip_tags is not working properly.
This regex will clean all tags opening, closing and comments tags. this is simple solution, you can make regex strict. instead of \w+ you can use (?:td|span|div…and so on) to specify which tags you want to clean.