mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 23:16:46 +00:00
fix: code block
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
width: calc(100% - var(--box-margin));
|
||||
}
|
||||
|
||||
> pre {
|
||||
width: calc(100% - var(--box-margin));
|
||||
max-width: 456px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.tgme_widget_message_link_preview {
|
||||
margin-top: 16px;
|
||||
display: none;
|
||||
|
||||
@@ -112,8 +112,10 @@ function modifyHTMLContent($, content, { index } = {}) {
|
||||
})
|
||||
$(content).find('pre').each((_index, pre) => {
|
||||
try {
|
||||
$(pre).find('br')?.replaceWith('\n')
|
||||
|
||||
const code = $(pre).text()
|
||||
const language = flourite(code, { shiki: true })?.language
|
||||
const language = flourite(code, { shiki: true, noUnknown: true })?.language || 'text'
|
||||
const highlightedCode = prism.highlight(code, prism.languages[language], language)
|
||||
$(pre).html(`<code class="language-${language}">${highlightedCode}</code>`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user