Unnecessary and excessive newlines in plain text part of newsletters

Issue Summary

  • Ghost.io generated emails sometimes have an extraordinary number of unnecessary newlines in the plain text part of the email (e.g. one newsletter I get has 28 new lines before the first text appears in the email).

  • This seems to be because the SDK html-to-plaintext package by default has the preserveNewlines setting set to true. This means that any new-lines in the original html are preserved (not line breaks, but \n in the source html).

  • This was raised by someone in a GitHub issue once: Plain text view · Issue #20015 · TryGhost/Ghost · GitHub

  • Image of plain text from email generated by ghost below:

Possible resolution:

1 Like

Are you willing to update your patch (e.g. fix linter issues and add tests)? If so, I’d suggest creating the PR referencing the issue/topic :slight_smile:

Sure, happy to work on that. Just wanted to get some basic feedback first. Thank you!

1 Like

I’ve noticed this too — newsletters with excessive newlines in the plain text version. It seems to be caused by ghost’s use of the html-to-plaintext package, which by default preserves all newlines from the original html. This can result in unnecessary blank lines before the actual content appears.

one possible fix is to modify how ghost handles these newlines, ensuring that only meaningful line breaks are preserved. a proposed patch has been suggested to address this issue. If you’re comfortable with making changes to your ghost setup, you might consider applying this patch to see if it resolves the problem.

Let me know if you need assistance with implementing this solution or have any other questions.