[feat] regex flags, fix display
This commit is contained in:
@@ -35,9 +35,6 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
|
||||
|
||||
export async function ParseMarkdown(data:string, char:(character | groupChat) = null, mode:'normal'|'back' = 'normal') {
|
||||
if(char && char.type !== 'group'){
|
||||
if(char.customscript){
|
||||
data = processScript(char, data, 'editdisplay')
|
||||
}
|
||||
if(char.additionalAssets){
|
||||
for(const asset of char.additionalAssets){
|
||||
const assetPath = await getFileSrc(asset[1])
|
||||
@@ -51,6 +48,9 @@ export async function ParseMarkdown(data:string, char:(character | groupChat) =
|
||||
}
|
||||
}
|
||||
}
|
||||
if(char){
|
||||
data = processScript(char, data, 'editdisplay')
|
||||
}
|
||||
return DOMPurify.sanitize(convertor.makeHtml(data), {
|
||||
ADD_TAGS: ["iframe"],
|
||||
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling"],
|
||||
|
||||
@@ -63,7 +63,6 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] {
|
||||
for (const word of words) {
|
||||
for (let char of chars) {
|
||||
const charNameChunks = getWords(findCharacterbyId(char.id).name)
|
||||
console.log(charNameChunks)
|
||||
|
||||
if (charNameChunks.includes(word)) {
|
||||
order.push(char);
|
||||
@@ -96,8 +95,11 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] {
|
||||
}
|
||||
|
||||
function getWords(data:string){
|
||||
const matches = data.match(/\b\w+\b/gmi)
|
||||
const matches = data.split(/\n| /g)
|
||||
let words:string[] = []
|
||||
if(!matches){
|
||||
return [data]
|
||||
}
|
||||
for(const match of matches){
|
||||
words.push(match.toLocaleLowerCase())
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export function processScriptFull(char:character|groupChat, data:string, mode:Sc
|
||||
const scripts = (db.globalscript ?? []).concat(char.customscript)
|
||||
for (const script of scripts){
|
||||
if(script.type === mode){
|
||||
const reg = new RegExp(script.in,'g')
|
||||
const reg = new RegExp(script.in, script.ableFlag ? script.flag : 'g')
|
||||
const outScript = script.out
|
||||
if(outScript.startsWith('@@') && reg.test(data)){
|
||||
if(outScript.startsWith('@@emo ')){
|
||||
|
||||
@@ -267,10 +267,12 @@ export function setDatabase(data:Database){
|
||||
|
||||
|
||||
export interface customscript{
|
||||
comment: string;
|
||||
in:string
|
||||
out:string
|
||||
type:string
|
||||
comment: string;
|
||||
in:string
|
||||
out:string
|
||||
type:string
|
||||
flag?:string
|
||||
ableFlag?:boolean
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user