From 656f8265fca408ecc22e0641d072e2bf1dfca072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ALEXANDER=20QUADRATUS=20/=E1=BC=88=CE=BB=CE=AD=CE=BE=CE=B1?= =?UTF-8?q?=CE=BD=CE=B4=CF=81=CE=BF=CF=82=20=CE=9A=CE=BF=CE=B4=CF=81?= =?UTF-8?q?=E1=BE=B6=CF=84=CE=BF=CF=82/?= Date: Sun, 7 Sep 2025 19:38:18 +0700 Subject: [PATCH] fix: plaintext JSON feed with only content_text is not displaying new lines --- src-tauri/src/structs/article.rs | 17 +++++++++++++++-- src/components/utils/SanitizeHTML.tsx | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/structs/article.rs b/src-tauri/src/structs/article.rs index e39c15b..7d6a7f9 100644 --- a/src-tauri/src/structs/article.rs +++ b/src-tauri/src/structs/article.rs @@ -21,9 +21,22 @@ impl From for Article { None => String::from("No title found, please report this issue."), }; let content = match entry.content { - Some(c) => c.body.unwrap(), + Some(c) => c.body.unwrap() + .replace('&', "&") + .replace('<', "<") + .replace('>', ">") + .replace('\n', "
\n") + .replace('\t', "    "), None => match entry.summary { - Some(s) => s.content, + Some(s) => { + // Convert plain text to HTML preserving formatting + s.content + .replace('&', "&") + .replace('<', "<") + .replace('>', ">") + .replace('\n', "
\n") + .replace('\t', "    ") + }, None => String::from("No content found, please report this issue."), }, }; diff --git a/src/components/utils/SanitizeHTML.tsx b/src/components/utils/SanitizeHTML.tsx index d073182..d35f324 100644 --- a/src/components/utils/SanitizeHTML.tsx +++ b/src/components/utils/SanitizeHTML.tsx @@ -58,7 +58,7 @@ export default function SanitizeHTML({ html, limit = 0 }: SanitizeHTMLProps) { return limit === 0 ? treated - : `${treated.slice(0, limit).replaceAll('\n', ' ').trim()}...`; + : `${treated.slice(0, limit).trim()}...`; }, [html, limit]); return (