I found a wonderful html truncation library, truncate.js that handles about 99% of my needs. But I have one unpleasant problem that I am facing. I have a requirement that requires βShow moreβ to be placed at the end of a certain number of lines for a series of messages ... that this library manages to achieve for a block of text ... but when it comes to multi-line text shows, it is no longer set correctly.
I did a plunker to demonstrate this problem. All I want is to be able to place more in the same position for multi-line text as well as for a block of text sitting on the same page.
My first attempt was to add prev () to the truncateNestedNodeEnd function
if ($clipNode.length) { if ($.inArray(element.tagName.toLowerCase(), BLOCK_TAGS) >= 0) { // Certain elements like <li> should not be appended to. $element.after($clipNode); } else { //edited this line to add prev() //$element.append($clipNode) $element.prev().append($clipNode); } }`

Which gives me what I want for multi-line text, but then breaks down the original functionality for a block of text, as shown in the plunker. How can I make this function work for two cases. I still want to show more to appear on the yellow part when these two entries are sitting on the same page.
source share