Commit 04e2b6e2 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

chore: format

parent 9f0c9d97
......@@ -159,7 +159,7 @@
const res = await synthesizeOpenAISpeech(
localStorage.token,
$settings?.audio?.tts?.defaultVoice === $config.audio.tts.voice
? $settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice
? ($settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice)
: $config?.audio?.tts?.voice,
sentence
).catch((error) => {
......
......@@ -9,7 +9,7 @@ const DELIMITER_LIST = [
{ left: '( ', right: ' )', display: false },
{ left: '\\[', right: '\\]', display: true },
{ left: '[', right: ']', display: true }
]
];
// const DELIMITER_LIST = [
// { left: '$$', right: '$$', display: false },
......@@ -27,7 +27,7 @@ function escapeRegex(string) {
}
function generateRegexRules(delimiters) {
delimiters.forEach(delimiter => {
delimiters.forEach((delimiter) => {
const { left, right } = delimiter;
// Ensure regex-safe delimiters
const escapedLeft = escapeRegex(left);
......@@ -35,7 +35,9 @@ function generateRegexRules(delimiters) {
// Inline pattern - Capture group $1, token content, followed by end delimiter and normal punctuation marks.
// Example: $text$
inlinePatterns.push(`${escapedLeft}((?:\\\\.|[^\\\\\\n])*?(?:\\\\.|[^\\\\\\n${escapedRight}]))${escapedRight}`);
inlinePatterns.push(
`${escapedLeft}((?:\\\\.|[^\\\\\\n])*?(?:\\\\.|[^\\\\\\n${escapedRight}]))${escapedRight}`
);
// Block pattern - Starts and ends with the delimiter on new lines. Example:
// $$\ncontent here\n$$
......@@ -50,19 +52,19 @@ function generateRegexRules(delimiters) {
const { inlineRule, blockRule } = generateRegexRules(DELIMITER_LIST);
export default function(options = {}) {
export default function (options = {}) {
return {
extensions: [
inlineKatex(options, createRenderer(options, false)),
blockKatex(options, createRenderer(options, true)),
],
blockKatex(options, createRenderer(options, true))
]
};
}
function createRenderer(options, newlineAfter) {
return (token) => katex.renderToString(token.text, { ...options, displayMode: token.displayMode }) + (newlineAfter ? '\n' : '');
return (token) =>
katex.renderToString(token.text, { ...options, displayMode: token.displayMode }) +
(newlineAfter ? '\n' : '');
}
function inlineKatex(options, renderer) {
......@@ -95,16 +97,19 @@ function inlineKatex(options, renderer) {
const match = src.match(ruleReg);
if (match) {
const text = match.slice(2).filter((item) => item).find((item) => item.trim());
const text = match
.slice(2)
.filter((item) => item)
.find((item) => item.trim());
return {
type: 'inlineKatex',
raw: match[0],
text: text,
text: text
};
}
},
renderer,
renderer
};
}
......@@ -116,16 +121,18 @@ function blockKatex(options, renderer) {
const match = src.match(blockRule);
if (match) {
const text = match.slice(2).filter((item) => item).find((item) => item.trim());
const text = match
.slice(2)
.filter((item) => item)
.find((item) => item.trim());
return {
type: 'blockKatex',
raw: match[0],
text: text,
text: text
};
}
},
renderer,
renderer
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment