Agent-Logs-Url: https://github.com/purocean/yn/sessions/423ca3b8-9674-4d0f-98d1-bc1fd5c33c5d Co-authored-by: purocean <7115690+purocean@users.noreply.github.com>
1.5 KiB
enableMacro, define
| enableMacro | define | ||||
|---|---|---|---|---|---|
| true |
|
Macro Replacement Test
This document tests the macro replacement feature ([= expression =]) of Yank Note.
Note
: Macros require
enableMacro: truein front matter to work.
Basic Expressions
Simple math: [= 1 + 2 =]
String operation: [= 'Hello' + ' ' + 'World' =]
Ternary: [= true ? 'Yes' : 'No' =]
Built-in Variables
Document Information ($doc)
Document basename: [= $doc.basename =]
Document name: [= $doc.name =]
Sequence Numbering ($seq)
Figure [= $seq('figure') =]: First diagram
Figure [= $seq('figure') =]: Second diagram
Figure [= $seq('figure') =]: Third diagram
Table [= $seq('table') =]: First table
Table [= $seq('table') =]: Second table
Variable Export ($export)
[= $export('greeting', 'Hello from Yank Note') =]
The exported value is: [= greeting =]
[= $export('count', 42) =]
The count is: [= count =]
Date and Time
Current timestamp: [= new Date().toISOString() =]
Year: [= new Date().getFullYear() =]
Conditional Content
[= 1 > 0 ? '✅ Condition is true' : '❌ Condition is false' =]
Text Define Replacement
The month is: --February--
中文月份: --二月--
Complex Expressions
Array operation: [= [1,2,3,4,5].reduce((a,b) => a+b, 0) =]
String repeat: [= '⭐'.repeat(5) =]
Include Other Documents
After Macro Hook
[= $afterMacro(() => { /* post-processing logic */ }) =]