From 9cee85f303deaaa4f5e41b4e05d822ee0ba2ee4d Mon Sep 17 00:00:00 2001 From: purocean Date: Fri, 5 Nov 2021 11:32:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AE=8F=E6=9B=BF=E6=8D=A2):=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E5=90=88=E7=AC=A6=E5=8F=B7=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/FEATURES.md | 5 ++++- src/renderer/plugins/markdown-macro.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/help/FEATURES.md b/help/FEATURES.md index 0aa9abfe..ae5ae82c 100644 --- a/help/FEATURES.md +++ b/help/FEATURES.md @@ -443,7 +443,9 @@ Yank Note 运行你在页面中嵌入宏,用以动态的替换文档。 <= => ``` -其中 `expression` 是需要执行的 js 代码。 +其中 `expression` 是需要执行的 js 表达式。 + +如果表达式中需要包含 <\= 或 =\> 请输入 `<\=` 或 `=\>` 转义替换 ### 示例 @@ -451,6 +453,7 @@ Yank Note 运行你在页面中嵌入宏,用以动态的替换文档。 - 自定义变量: <= customVar => - 当前文档名: <= $doc.basename => - 当前时间: <= ctx.lib.dayjs().format('YYYY-MM-DD HH:mm') => +- 限定符转义: <= (1 <\= 3) ? 'result =\> true' : 'result =\> false' => - 四则运算: <= (1 + 2) / 2 => - 九九乘法表 <= diff --git a/src/renderer/plugins/markdown-macro.ts b/src/renderer/plugins/markdown-macro.ts index b104e747..3c009d51 100644 --- a/src/renderer/plugins/markdown-macro.ts +++ b/src/renderer/plugins/markdown-macro.ts @@ -59,6 +59,7 @@ export default { const expression = match .substring(2, match.length - 2) .trim() + .replace(/(?:=\\>|<\\=)/g, x => x.replace('\\', '')) const result = macro(expression, vars)