remove blank lines and spaces from plain parts (#280)

This commit is contained in:
Clément DOUIN 2022-02-01 15:47:54 +01:00
parent b6669fba57
commit 1dbd7a4893
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
2 changed files with 10 additions and 2 deletions

View file

@ -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] - Vim plugin get focused msg id [#268]
- Nix run issue [#272] - Nix run issue [#272]
- Range not displayed when fetch fails [#276] - Range not displayed when fetch fails [#276]
- Blank lines and spaces in `text/plain` parts [#280]
### Removed ### 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 [#272]: https://github.com/soywod/himalaya/issues/272
[#273]: https://github.com/soywod/himalaya/issues/273 [#273]: https://github.com/soywod/himalaya/issues/273
[#276]: https://github.com/soywod/himalaya/issues/276 [#276]: https://github.com/soywod/himalaya/issues/276
[#280]: https://github.com/soywod/himalaya/issues/280

View file

@ -106,15 +106,21 @@ impl Msg {
.replace_all(&sanitized_html, " ") .replace_all(&sanitized_html, " ")
.to_string(); .to_string();
// Merge new line chars // Merge new line chars
let sanitized_html = Regex::new(r"(\r?\n ?){2,}") let sanitized_html = Regex::new(r"(\r?\n *){2,}")
.unwrap() .unwrap()
.replace_all(&sanitized_html, "\n\n") .replace_all(&sanitized_html, "\n\n")
.to_string(); .to_string();
// Decode HTML entities // Decode HTML entities
let sanitized_html = html_escape::decode_html_entities(&sanitized_html).to_string(); let sanitized_html = html_escape::decode_html_entities(&sanitized_html).to_string();
sanitized_html sanitized_html
} else { } else {
plain let sanitized_plain = Regex::new(r"(\r?\n *){2,}")
.unwrap()
.replace_all(&plain, "\n\n")
.to_string();
sanitized_plain
} }
} }