fix: template render

remove: do not support markdown backtick grammar
This commit is contained in:
windingwind 2024-10-13 22:55:58 +02:00
parent 49c6c0ba9b
commit 673c0bbce0
2 changed files with 2 additions and 8 deletions

View File

@ -90,16 +90,10 @@ async function runTemplate(
},
);
// Match the backticks not inside a `${}` and replace them with a placeholder
// Not inside a `${}`
templateText = templateText.replace(/`(?![^${]*\})(?<!\${[^`]*`)/g, "__bt__");
try {
const func = new AsyncFunction(argString, "return `" + templateText + "`");
let res = (await func(...argList)) as string;
if (useMarkdown) {
// Replace the placeholder back to backticks
res = res.replace(/__bt__/g, "`");
res = await addon.api.convert.md2html(res);
}
ztoolkit.log(res);

View File

@ -723,11 +723,11 @@ const formatStore = [
},
{
name: "monospaced",
code: "`${text}`",
code: "<code>${text}</code>",
},
{
name: "code",
code: "\n```\n${text}\n```\n",
code: "\n<pre>\n${text}\n</pre>\n",
},
{
name: "table",