diff --git a/CHANGELOG.md b/CHANGELOG.md index 0865fdf..6c6d209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Vim plugin get focused msg id [#268] - Nix run issue [#272] - Range not displayed when fetch fails [#276] +- Blank lines and spaces in `text/plain` parts [#280] ### Removed @@ -372,3 +373,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#272]: https://github.com/soywod/himalaya/issues/272 [#273]: https://github.com/soywod/himalaya/issues/273 [#276]: https://github.com/soywod/himalaya/issues/276 +[#280]: https://github.com/soywod/himalaya/issues/280 diff --git a/src/domain/msg/msg_entity.rs b/src/domain/msg/msg_entity.rs index 13f2ec1..145a945 100644 --- a/src/domain/msg/msg_entity.rs +++ b/src/domain/msg/msg_entity.rs @@ -106,15 +106,21 @@ impl Msg { .replace_all(&sanitized_html, " ") .to_string(); // Merge new line chars - let sanitized_html = Regex::new(r"(\r?\n ?){2,}") + let sanitized_html = Regex::new(r"(\r?\n *){2,}") .unwrap() .replace_all(&sanitized_html, "\n\n") .to_string(); // Decode HTML entities let sanitized_html = html_escape::decode_html_entities(&sanitized_html).to_string(); + sanitized_html } else { - plain + let sanitized_plain = Regex::new(r"(\r?\n *){2,}") + .unwrap() + .replace_all(&plain, "\n\n") + .to_string(); + + sanitized_plain } }