The core function shorten_text is supposed to close any HTML tags that it cuts off. However this only occurs sometimes, depending on the parameters. The sequence of events that occurs is:
- Function divides input into blocks starting with each tag (open/close/empty)
- Loops through these input 'lines' until there is more text than the shorten_text allows
At this point, any tags that are not closed (ie that would be closed in future 'lines') are safe - they will be closed.
- Goes back looking for a space or suitable breakpoint to chop the text so it is under the limit
During this process close tags may be chopped off. These are not re-added.