Skip to content

Commit 656f826

Browse files
committed
fix: plaintext JSON feed with only content_text is not displaying new lines
1 parent 3d6c217 commit 656f826

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src-tauri/src/structs/article.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,22 @@ impl From<Entry> for Article {
2121
None => String::from("No title found, please report this issue."),
2222
};
2323
let content = match entry.content {
24-
Some(c) => c.body.unwrap(),
24+
Some(c) => c.body.unwrap()
25+
.replace('&', "&amp;")
26+
.replace('<', "&lt;")
27+
.replace('>', "&gt;")
28+
.replace('\n', "<br>\n")
29+
.replace('\t', "&nbsp;&nbsp;&nbsp;&nbsp;"),
2530
None => match entry.summary {
26-
Some(s) => s.content,
31+
Some(s) => {
32+
// Convert plain text to HTML preserving formatting
33+
s.content
34+
.replace('&', "&amp;")
35+
.replace('<', "&lt;")
36+
.replace('>', "&gt;")
37+
.replace('\n', "<br>\n")
38+
.replace('\t', "&nbsp;&nbsp;&nbsp;&nbsp;")
39+
},
2740
None => String::from("No content found, please report this issue."),
2841
},
2942
};

src/components/utils/SanitizeHTML.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function SanitizeHTML({ html, limit = 0 }: SanitizeHTMLProps) {
5858

5959
return limit === 0
6060
? treated
61-
: `${treated.slice(0, limit).replaceAll('\n', ' ').trim()}...`;
61+
: `${treated.slice(0, limit).trim()}...`;
6262
}, [html, limit]);
6363

6464
return (

0 commit comments

Comments
 (0)