diff --git a/index.html b/index.html index 9885f56..cfc4a72 100644 --- a/index.html +++ b/index.html @@ -2922,6 +2922,16 @@ //attempt to load settings function init() { + //polyfill for forEach + if (window.NodeList && !NodeList.prototype.forEach) { + NodeList.prototype.forEach = function (callback, thisArg) { + thisArg = thisArg || window; + for (var i = 0; i < this.length; i++) { + callback.call(thisArg, this[i], i, this); + } + }; + } + //uncompress compacted scenarios for(let i=0;i { newbodystr = newbodystr.replace(``, part); }); // Bring back the embedded HTML parts. newbodystr = applyStylizedCodeBlocks(); // Apply the code-block styling, if markdown is used. } - return newbodystr.replaceAll('\r\n','
').replaceAll('\n','
') + '


'; // Finally, convert newlines to HTML format and return the stylized string. + let ret = newbodystr; + ret = replaceAll(ret,'\r\n','
'); + ret = replaceAll(ret,'\n','
'); + return ret + '


'; // Finally, convert newlines to HTML format and return the stylized string. // Helper functions to allow styling the chat log properly. These affect both the background of the chat bubbles and its content. @@ -8437,8 +8457,14 @@ function applyStylizedCodeBlocks() { let blocks = newbodystr.split(/(```[\s\S]*?\n[\s\S]*?```)/g); for (var i = 0; i < blocks.length; i++) { - if (blocks[i].startsWith('```')) { blocks[i] = blocks[i].replace(/```[\s\S]*?\n([\s\S]*?)```/g, `

$1

`); } - else { blocks[i] = blocks[i].replaceAll('```','`').replaceAll('``','`').replaceAll(/`(.*?)`/g, `$1`);} + if (blocks[i].startsWith('```')) { blocks[i] = blocks[i].replace(/```[\s\S]*?\n([\s\S]*?)```/g, `

$1

`); } + else { + let bi = blocks[i]; + bi = replaceAll(bi,'```','`'); + bi = replaceAll(bi,'``','`'); + bi = bi.replace(/`(.*?)`/g, `$1`); + blocks[i] = bi; + } } return blocks.join(''); } @@ -8446,7 +8472,10 @@ function updateTextPreview() { let preview = `You are Mikago, a prestigious bot that's a supervillain.\n\nRoleplay in first person, be prestigious, don't be a bot. This is a fantasy world.\n\nCode blocks should be wrapped in triple backticks, like so:\nqqq\n