Missing indicator on html tag cut
Closed this issue · 2 comments
Hi,
given this example:
const tc = require('text-clipper').default
tc('<p>12345</p><p>67890</p>', 8, {
html: true,
breakWords: true,
indicator: '...',
})
I would expect this output:
<p>12345...</p>
// or
<p>12345</p><p>...</p>
Instead, I got:
<p>12345</p>
What do you think?
Thanks for the report. I can confirm the current output is as intended, because as the README describes, the indicator is not inserted at a linebreak, which also applies to the start of a new paragraph. The rationale for this is that users are expected to display a “Read more” link or such anyway, so there shouldn’t be any confusion and the extra ellipses tend to look off in such cases.
That said, you’re not the first to raise this question, so it seems not to be entirely intuitive to everyone. If you’re interested I’d welcome a PR to make this behavior configurable. I think an insertIndicatorAtLinebreak
option would be reasonable to have. If such option were to be set to true
, I think the output <p>12345...</p>
would be preferred indeed.
Implemented at last :)