When trimming HTML articles we need to respect HTML objects. Length of those can vary widely so we need to figure out how to split them without upsetting the TAGS.
There are several ways of trimming the HTML objects. The one I’ve chosen for HCH website is powered by a native PHP library called DOM.
Only two additional wrappers are needed: one to wrap the trimmed part of the tag containing the division and other wrapper for the rest of the article if we choose to keep it. It is genius in its simplicity! It wasn’t really my idea… I’ve stolen it from Facebook :-) wooopsy