fix embed wrapper not invoking immediately

This commit is contained in:
Daniel Avila 2023-02-25 10:33:26 -05:00
parent 0ee31f0443
commit 8e5148b390
2 changed files with 5 additions and 21 deletions

View file

@ -38,7 +38,7 @@ export default function TextWrapper({ text }) {
let embedTest = false; let embedTest = false;
// to match unenclosed code blocks // 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) { // if (text.match(/```/g)?.length === 1) {
// const splitString = text.split('```')[1].split(/\s+/).slice(1).join('').trim(); // const splitString = text.split('```')[1].split(/\s+/).slice(1).join('').trim();
// embedTest = splitString.length > 0; // embedTest = splitString.length > 0;

View file

@ -2,11 +2,11 @@ const regex = /```([^`\n]*?)\n([\s\S]*?)\n```/g;
const unenclosedCodeTest = (text) => { const unenclosedCodeTest = (text) => {
let workingText = text; let workingText = text;
if (workingText.startsWith('<') || (!workingText.startsWith('`') && workingText.match(/```/g)?.length === 1)) { // if (workingText.startsWith('<') || (!workingText.startsWith('`') && workingText.match(/```/g)?.length === 1)) {
workingText = `\`\`\`${workingText}` // workingText = `\`\`\`${workingText}`
} // }
return workingText; return workingText.trim();
}; };
export default function regexSplit(string) { 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; return output;
} }