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 (