Add code syntax highlight

This commit is contained in:
SillyLossy
2023-04-28 22:49:43 +03:00
parent a53531f320
commit 6dd1e0421c
4 changed files with 1373 additions and 0 deletions

View File

@ -165,6 +165,7 @@ export {
window["SillyTavern"] = {};
const gpt3 = new GPT3BrowserTokenizer({ type: 'gpt3' });
hljs.addPlugin({"before:highlightElement": ({ el }) => { el.textContent = el.innerText } });
let converter = new showdown.Converter({
emoji: "true",
underline: "true",
@ -974,6 +975,7 @@ function addCopyToCodeBlocks(messageElement) {
document.body.removeChild(copiedMsg);
}, 2500);
});
hljs.highlightElement(codeBlocks.get(i));
}
}
@ -1299,6 +1301,7 @@ class StreamingProcessor {
onFinishStreaming(messageId, text) {
this.hideStopButton(this.messageId);
this.onProgressStreaming(messageId, text);
addCopyToCodeBlocks($(`#chat .mes[mesid="${messageId}"]`));
playMessageSound();
saveChatConditional();
activateSendButtons();