Compare commits

..

2 Commits

Author SHA1 Message Date
YangFong
36dd217d92
Merge 67ef9dc21c into 23de6453a3 2024-12-25 08:24:05 +08:00
Libin YANG
23de6453a3
fix: render tab to spaces (#498)
Some checks failed
Build and Deploy / build-and-deploy (push) Has been skipped
Build and Push Docker Images / build (push) Failing after 32s
#497
2024-12-24 11:55:57 +08:00

View File

@ -174,6 +174,8 @@ export function initRenderer(opts: IOpts) {
const langText = lang.split(` `)[0] const langText = lang.split(` `)[0]
const language = hljs.getLanguage(langText) ? langText : `plaintext` const language = hljs.getLanguage(langText) ? langText : `plaintext`
let highlighted = hljs.highlight(text, { language }).value let highlighted = hljs.highlight(text, { language }).value
// tab to 4 spaces
highlighted = highlighted.replace(/\t/g, ' ')
highlighted = highlighted highlighted = highlighted
.replace(/\r\n/g, `<br/>`) .replace(/\r\n/g, `<br/>`)
.replace(/\n/g, `<br/>`) .replace(/\n/g, `<br/>`)