[feat] automark plugin
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { language } from "src/lang";
|
||||
import { alertConfirm } from "src/ts/alert";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import { importPlugin } from "src/ts/process/plugins";
|
||||
import { importPlugin } from "src/ts/plugins/plugins";
|
||||
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.plugin}</h2>
|
||||
|
||||
56
src/ts/plugins/automark.ts
Normal file
56
src/ts/plugins/automark.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
const reg:[RegExp,string][] = []
|
||||
|
||||
|
||||
export function autoMarkPlugin(data:string){
|
||||
if(reg.length === 0){
|
||||
const pluginRegex = [
|
||||
{
|
||||
"in": "“|”",
|
||||
"out": "\"",
|
||||
"flag": "g"
|
||||
},
|
||||
{
|
||||
"in": "‘|’",
|
||||
"out": "'",
|
||||
"flag": "g"
|
||||
},
|
||||
{
|
||||
"in": "^(?!\\d\\.)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])|(?<=^\\[.*\\] *|^\\(.*\\) *)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])",
|
||||
"out": "<em>$1$2",
|
||||
"flag": "gm"
|
||||
},
|
||||
{
|
||||
"in": "(?<!^ +.*)(\".*|<em>.*)(?<!\")$",
|
||||
"out": "$1</em>",
|
||||
"flag": "gm"
|
||||
},
|
||||
{
|
||||
"in": "(?<=<em>.*|^\".*)( +\"[\\S])|(?<=<em>.*|\" +.*)( *\\[)",
|
||||
"out": "</em>$1$2",
|
||||
"flag": "gm"
|
||||
},
|
||||
{
|
||||
"in": "(?<=^\".*|<\\/em>.*)([\\S]\" +|[\\S]\"(?=[,.…ㄱ-ㅎ가-힣]))|(?<=<\\/em>.*)( *\\] *)",
|
||||
"out": "$1$2<em>",
|
||||
"flag": "gm"
|
||||
},
|
||||
{
|
||||
"in": "(?<=<em>.*? +|\\[|\\[.* +|\\(|\\(.* +|\"|\".*? +)(?<!style=.*)(')|(?<=<em>)('[\\wㄱ-ㅎ가-힣])",
|
||||
"out": "<strong><em>$1$2",
|
||||
"flag": "gm"
|
||||
},
|
||||
{
|
||||
"in": "(?<=<strong><em>')(.*?')(?= +.+?|[ㄱ-ㅎ가-힣?!:;,.…—-])|(?<=<strong><em>'.*)(')(?=<\\/em>|\")|(?<=\\(<strong><em>')(?=\\))",
|
||||
"out": "$1$2</em></strong>",
|
||||
"flag": "gm"
|
||||
}
|
||||
]
|
||||
for(const r of pluginRegex){
|
||||
reg.push([new RegExp(r.in, r.flag),r.out])
|
||||
}
|
||||
}
|
||||
for(let i=0;i<reg.length;i++){
|
||||
data = data.replace(reg[i][0], reg[i][1])
|
||||
}
|
||||
return data
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { language } from "../../lang";
|
||||
import { alertError } from "../alert";
|
||||
import { DataBase } from "../storage/database";
|
||||
import { checkNullish, selectSingleFile, sleep } from "../util";
|
||||
import type { OpenAIChat } from ".";
|
||||
import type { OpenAIChat } from "../process";
|
||||
import { globalFetch } from "../storage/globalApi";
|
||||
import { selectedCharID } from "../stores";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import type { OpenAIChat, OpenAIChatFull } from ".";
|
||||
import { DataBase, setDatabase, type character } from "../storage/database";
|
||||
import { pluginProcess } from "./plugins";
|
||||
import { pluginProcess } from "../plugins/plugins";
|
||||
import { language } from "../../lang";
|
||||
import { stringlizeChat, unstringlizeChat } from "./stringlize";
|
||||
import { globalFetch, isNodeServer, isTauri } from "../storage/globalApi";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { checkNullish, selectSingleFile } from '../util';
|
||||
import { changeLanguage, language } from '../../lang';
|
||||
import type { RisuPlugin } from '../process/plugins';
|
||||
import type { RisuPlugin } from '../plugins/plugins';
|
||||
import { downloadFile, saveAsset as saveImageGlobal } from './globalApi';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { defaultAutoSuggestPrompt, defaultJailbreak, defaultMainPrompt } from './defaultPrompts';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { appWindow } from "@tauri-apps/api/window";
|
||||
import { checkOldDomain, checkUpdate } from "../update";
|
||||
import { selectedCharID } from "../stores";
|
||||
import { Body, ResponseType, fetch as TauriFetch } from "@tauri-apps/api/http";
|
||||
import { loadPlugins } from "../process/plugins";
|
||||
import { loadPlugins } from "../plugins/plugins";
|
||||
import { alertError, alertStore } from "../alert";
|
||||
import { checkDriverInit, syncDrive } from "../drive/drive";
|
||||
import { hasher } from "../parser";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { get } from "svelte/store"
|
||||
import { translatorPlugin } from "../process/plugins"
|
||||
import { translatorPlugin } from "../plugins/plugins"
|
||||
import { DataBase } from "../storage/database"
|
||||
|
||||
let cache={
|
||||
|
||||
Reference in New Issue
Block a user