Skip to content

Commit b8fd039

Browse files
committed
sanitize HTML and support emoji
1 parent 407e794 commit b8fd039

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

caroline/html/js/yaml2html.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
import { marked } from "marked";
2+
import DOMPurify from 'dompurify';
3+
import * as emoji from 'node-emoji'
4+
5+
6+
function parse_content(text){
7+
return DOMPurify.sanitize(emoji.emojify((marked.parse(text))));
8+
}
29

310
export function yaml2html(slide ){
411
console.log(slide);
@@ -10,7 +17,7 @@ export function yaml2html(slide ){
1017
if ("fontSize" in slide){
1118
fontSize = slide["fontSize"];
1219
}
13-
return `<div class='spancenter' style='font-size:${fontSize}fem'>${marked.parse(slide["spanCenterText"])}</div>`;
20+
return `<div class='spancenter' style='font-size:${fontSize}fem'>${parse_content(slide["spanCenterText"])}</div>`;
1421
}
1522
}
1623

caroline/html/package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

caroline/html/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"markdown-it": "^14.1.0",
4343
"markdown-it-mathjax": "^2.0.0",
4444
"marked": "^16.1.1",
45+
"node-emoji": "^2.2.0",
4546
"pdfjs-dist": "^4.10.38",
4647
"socket.io-client": "^4.8.1",
4748
"yaml": "^2.7.0"

0 commit comments

Comments
 (0)