No idea what Youtube does, but my first attempt would be:
- (Strip all illegal characters)
- (Censor profanity)
- If less than e.g. 600 characters, allow the whole comment.
- If any sentence ends between character 500 and 600, cut after the last sentence end.
- Otherwise, if any word ends between character 500 and 600, cut at the last one.
- Otherwise just cut at 600.
Then, as a final step:
- If the result of previous steps has more than e.g. 3 newlines, hide from the 3rd newline.
And a bonus feature:
![listen_to_yourself[1].png](https://cdn.hashnode.com/res/hashnode/image/upload/v1552314572800/_VbkICt7L.png)