mirror of
https://github.com/purocean/yn.git
synced 2026-10-24 23:31:51 +08:00
feat(macro): add $seq method
This commit is contained in:
@@ -641,6 +641,7 @@ If the expression needs to contain [\= or =\], please enter `[\=` or `=\]` to es
|
||||
- application version: [= $ctx.version =]
|
||||
- current document name: [= $doc.basename =]
|
||||
- current time: [= $ctx.lib.dayjs().format('YYYY-MM-DD HH:mm') =]
|
||||
- sequence: [= $seq`Figure-` =] | [= $seq`Figure-` =] | [= $seq`Figure-` =] | [= $seq`Table-` =] | [= $seq`Table-` =]
|
||||
- qualifier escape: [= '[\= =\]' =]
|
||||
- Arithmetic: [= (1 + 2) / 2 =]
|
||||
- reference file (support 3 levels of nesting, you can use Front Matter variable defined in the target document):
|
||||
@@ -680,6 +681,7 @@ variable name | type | description
|
||||
`$afterMacro` | `(fn: (src: string) => string) => Result` | Define a macro-replaced callback function that can be used for further processing of the replaced text.
|
||||
`$noop` | `() => Result` | no operation, Used for holding text space
|
||||
`$doc` | `object` | Current document information
|
||||
`$seq` | `(label: string) => Result` | Sequence
|
||||
`$doc.basename` | `string` | File name of current document (no suffix)
|
||||
`$doc.name` | `string` | File name of current document
|
||||
`$doc.path` | `string` | Current document path
|
||||
|
||||
@@ -641,6 +641,7 @@ Front Matter 中的 `define` 字段可以定义一些文本替换映射。支持
|
||||
- 应用版本:[= $ctx.version =]
|
||||
- 当前文档名: [= $doc.basename =]
|
||||
- 当前时间: [= $ctx.lib.dayjs().format('YYYY-MM-DD HH:mm') =]
|
||||
- 计数器: [= $seq`图-` =] | [= $seq`图-` =] | [= $seq`图-` =] | [= $seq`表-` =] | [= $seq`表-` =]
|
||||
- 限定符转义: [= '[\= =\]' =]
|
||||
- 四则运算: [= (1 + 2) / 2 =]
|
||||
- 引用文件(支持最多嵌套 3 层,可使用目标文档中定义的 Front Matter 变量)
|
||||
@@ -679,6 +680,7 @@ Front Matter 中的 `define` 字段可以定义一些文本替换映射。支持
|
||||
`$export` | `(key: string, val: any) => Result` | 定义一个本文档可以使用的变量
|
||||
`$noop` | `() => Result` | 无操作函数,可用于文本占位使用
|
||||
`$afterMacro` | `(fn: (src: string) => string) => Result` | 定义一个宏替换后的回调函数,可用于对替换后的文本进行进一步处理。
|
||||
`$seq` | `(label: string) => Result` | 文档内部计数器
|
||||
`$doc` | `object` | 当前文档信息
|
||||
`$doc.basename` | `string` | 当前文档文件名(无后缀)
|
||||
`$doc.name` | `string` | 当前文档文件名
|
||||
|
||||
Reference in New Issue
Block a user