From 500cbd6f0217095541e5462d76282d8a40f116a9 Mon Sep 17 00:00:00 2001 From: jetstream0 <49297268+jetstream0@users.noreply.github.com> Date: Sat, 19 Aug 2023 03:45:36 +0200 Subject: [PATCH] feed fix --- index.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 03fa42c..3573f8a 100644 --- a/index.ts +++ b/index.ts @@ -111,6 +111,19 @@ let first_posts: PostMetadata[] = posts_metadata.slice(0, 5); //not truly the re const site_info: SiteInfo = _site_info; +function html_entity_convert(html: string) { + const entity_table = { + " ": " ", + "<": "<", + ">": ">", + }; + for (let i=0; i < Object.keys(entity_table).length; i++) { + let entity_name = Object.keys(entity_table)[i]; + html = html.replaceAll(entity_name, entity_table[entity_name]); + } + return html; +} + let posts_rss: RSSPost[] = first_posts.map((post) => { //get url let url: string = `${site_info.url}/posts/${post.slug}`; @@ -125,7 +138,7 @@ let posts_rss: RSSPost[] = first_posts.map((post) => { //get html let post_md_path: string = path.join(__dirname, `/posts/${post.filename}.md`); let md: string = readFileSync(post_md_path, "utf-8").replaceAll("\r", ""); - let html: string = parse_md_to_html(md); + let html: string = html_entity_convert(parse_md_to_html(md)); //turn into rsspost return { ...post,