[fix] use two tildes

This commit is contained in:
kwaroran
2023-12-31 03:41:24 +09:00
parent 85bf4f254b
commit a304d555ba
2 changed files with 18 additions and 8 deletions

View File

@@ -22,12 +22,22 @@ const mconverted = new Marked({
}
})
const safeConvertor = new showdown.Converter({
simpleLineBreaks: true,
strikethrough: true,
tables: true,
backslashEscapesHTMLTags: true
})
mconverted.use({
tokenizer: {
del(src) {
const cap = /^~~+(?=\S)([\s\S]*?\S)~~+/.exec(src);
if (cap) {
return {
type: 'del',
raw: cap[0],
text: cap[2],
tokens: []
};
}
return false;
}
}
});
@@ -176,7 +186,7 @@ export async function ParseMarkdown(data:string, charArg:(character|simpleCharac
}
export function parseMarkdownSafe(data:string) {
return DOMPurify.sanitize(safeConvertor.makeHtml(data), {
return DOMPurify.sanitize(mconverted.parse(data), {
FORBID_TAGS: ["a", "style"],
FORBID_ATTR: ["style", "href", "class"]
})

View File

@@ -265,7 +265,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
if(db.chainOfThought){
unformated.postEverything.push({
role: 'system',
content: `<instruction>before respond everything, Think step by step as a ai assistant how would you respond inside <Thoughts> xml tag.</instruction>`
content: `<instruction> - before respond everything, Think step by step as a ai assistant how would you respond inside <Thoughts> xml tag. this must be less than 5 paragraphs.</instruction>`
})
}