Skip to content

Commit

Permalink
Support trailing backslashes as newlines in RSS generation
Browse files Browse the repository at this point in the history
  • Loading branch information
m417z committed Sep 12, 2023
1 parent 34cd0d4 commit c924fc1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,20 @@ function generateRssFeed() {

const showdownConverter = new showdown.Converter();

const markdownToHtml = (markdown: string) => {
// Showdown doesn't support trailing backslashes as newlines. Use double
// spaces instead. https://github.com/showdownjs/showdown/issues/394
markdown = markdown.replace(/\\\n/g, ' \n');

return showdownConverter.makeHtml(markdown);
}

for (const feedItem of feedItems) {
feed.addItem({
title: feedItem.title,
id: feedItem.url + '#' + feedItem.commit,
link: feedItem.url,
content: showdownConverter.makeHtml(feedItem.content),
content: markdownToHtml(feedItem.content),
date: feedItem.date,
});
}
Expand All @@ -295,6 +303,9 @@ function generateRssFeed() {
}

async function main() {
fs.writeFileSync('updates.atom', generateRssFeed());
return;

const catalog = await generateModCatalog();
fs.writeFileSync('catalog.json', JSONstringifyOrder(catalog, 4));

Expand Down

0 comments on commit c924fc1

Please sign in to comment.