Skip to content

Commit 592c453

Browse files
committed
Deal with cross referenceable math in feeds
1 parent afbe0e1 commit 592c453

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/project/types/website/listing/website-listing-shared.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,23 @@ export function readRenderedContents(
365365
});
366366
}
367367

368+
// Cleans math tags and replaces with qquad
369+
const replaceTagRegex = /\/tag\{(.*)\}/g;
370+
const cleanMath = (contents?: string) => {
371+
if (!contents) {
372+
return undefined;
373+
} else {
374+
// /tag{1} > \qquad(1)
375+
return contents.replaceAll(replaceTagRegex, (_match, content) => {
376+
return `\\qquad{${content}}`;
377+
});
378+
}
379+
};
380+
368381
return {
369382
title: titleText,
370-
fullContents: mainEl?.innerHTML,
371-
firstPara: mainEl?.querySelector("p")?.innerHTML,
383+
fullContents: cleanMath(mainEl?.innerHTML),
384+
firstPara: cleanMath(mainEl?.querySelector("p")?.innerHTML),
372385
};
373386
}
374387

0 commit comments

Comments
 (0)