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
This commit is contained in:
Libin YANG 2024-12-24 11:55:57 +08:00 committed by GitHub
parent 03b0e73acb
commit 23de6453a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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/>`)