fix: template render
remove: do not support markdown backtick grammar
This commit is contained in:
parent
49c6c0ba9b
commit
673c0bbce0
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue