Add disable quote formating option
This commit is contained in:
@@ -230,8 +230,8 @@ export function updateTextTheme(){
|
||||
root.style.setProperty('--FontColorItalic', db.customTextTheme.FontColorItalic);
|
||||
root.style.setProperty('--FontColorBold', db.customTextTheme.FontColorBold);
|
||||
root.style.setProperty('--FontColorItalicBold', db.customTextTheme.FontColorItalicBold);
|
||||
root.style.setProperty('--FontColorQuote1', db.customTextTheme.FontColorQuote1);
|
||||
root.style.setProperty('--FontColorQuote2', db.customTextTheme.FontColorQuote2);
|
||||
root.style.setProperty('--FontColorQuote1', db.customTextTheme.FontColorQuote1 ?? '#8BE9FD');
|
||||
root.style.setProperty('--FontColorQuote2', db.customTextTheme.FontColorQuote2 ?? '#FFB86C');
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,19 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
|
||||
|
||||
|
||||
function renderMarkdown(md:markdownit, data:string){
|
||||
return md.render(data.replace(/“|”/g, '"').replace(/‘|’/g, "'"))
|
||||
.replace(/\uE9b0/gu, '<mark risu-mark="quote2">“')
|
||||
.replace(/\uE9b1/gu, '”</mark>')
|
||||
.replace(/\uE9b2/gu, '<mark risu-mark="quote1">‘')
|
||||
.replace(/\uE9b3/gu, '’</mark>')
|
||||
const db = get(DataBase)
|
||||
let text = md.render(data.replace(/“|”/g, '"').replace(/‘|’/g, "'"))
|
||||
|
||||
if(db?.unformatQuotes){
|
||||
text = text.replace(/\uE9b0/gu, '“').replace(/\uE9b1/gu, '”')
|
||||
text = text.replace(/\uE9b2/gu, '‘').replace(/\uE9b3/gu, '’')
|
||||
}
|
||||
else{
|
||||
text = text.replace(/\uE9b0/gu, '<mark risu-mark="quote2">“').replace(/\uE9b1/gu, '”</mark>')
|
||||
text = text.replace(/\uE9b2/gu, '<mark risu-mark="quote1">‘').replace(/\uE9b3/gu, '’</mark>')
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
async function renderHighlightableMarkdown(data:string) {
|
||||
|
||||
@@ -429,6 +429,7 @@ export function setDatabase(data:Database){
|
||||
timeout: 30
|
||||
}
|
||||
data.hideApiKey ??= true
|
||||
data.unformatQuotes ??= false
|
||||
|
||||
changeLanguage(data.language)
|
||||
DataBase.set(data)
|
||||
@@ -712,6 +713,7 @@ export interface Database{
|
||||
useLegacyGUI: boolean
|
||||
claudeCachingExperimental: boolean
|
||||
hideApiKey: boolean
|
||||
unformatQuotes: boolean
|
||||
}
|
||||
|
||||
export interface customscript{
|
||||
|
||||
Reference in New Issue
Block a user