mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
fix embed wrapper not invoking immediately
This commit is contained in:
parent
0ee31f0443
commit
8e5148b390
2 changed files with 5 additions and 21 deletions
|
|
@ -38,7 +38,7 @@ export default function TextWrapper({ text }) {
|
|||
let embedTest = false;
|
||||
|
||||
// to match unenclosed code blocks
|
||||
if (text.match(/```/g)?.length === 1 && text.match(/```(\w+)/)) {
|
||||
if (text.match(/```/g)?.length === 1) {
|
||||
// if (text.match(/```/g)?.length === 1) {
|
||||
// const splitString = text.split('```')[1].split(/\s+/).slice(1).join('').trim();
|
||||
// embedTest = splitString.length > 0;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ const regex = /```([^`\n]*?)\n([\s\S]*?)\n```/g;
|
|||
|
||||
const unenclosedCodeTest = (text) => {
|
||||
let workingText = text;
|
||||
if (workingText.startsWith('<') || (!workingText.startsWith('`') && workingText.match(/```/g)?.length === 1)) {
|
||||
workingText = `\`\`\`${workingText}`
|
||||
}
|
||||
// if (workingText.startsWith('<') || (!workingText.startsWith('`') && workingText.match(/```/g)?.length === 1)) {
|
||||
// workingText = `\`\`\`${workingText}`
|
||||
// }
|
||||
|
||||
return workingText;
|
||||
return workingText.trim();
|
||||
};
|
||||
|
||||
export default function regexSplit(string) {
|
||||
|
|
@ -36,21 +36,5 @@ export default function regexSplit(string) {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(output);
|
||||
|
||||
// for (let i = 0; i < matches.length; i++) {
|
||||
// const [fullMatch, language, code] = matches[i];
|
||||
// output.push(`\`\`\`${language}\n${code}\n\`\`\``);
|
||||
// if (i < matches.length - 1 && matches[i + 1]) {
|
||||
// const nextText = string.slice(matches[i].index + fullMatch.length, matches[i + 1].index);
|
||||
// output.push(nextText.trim());
|
||||
// } else if (i === matches.length - 1) {
|
||||
// const nextText = string.slice(matches[i].index + fullMatch.length);
|
||||
// output.push(nextText.trim());
|
||||
// }
|
||||
// }
|
||||
|
||||
// console.log(output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue