This commit is contained in:
Alexander Wang 2024-11-17 21:13:06 -08:00
parent 240060238c
commit c3fbf873bf
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 211 additions and 0 deletions

View file

@ -2865,6 +2865,22 @@ x*: {
tassert.Equal(t, "x2.ok", g.Objects[3].AbsID())
},
},
{
name: "var_in_markdown",
text: `vars: {
v: {
ok
}
}
x: |md
m${v}y
|
`,
assertions: func(t *testing.T, g *d2graph.Graph) {
tassert.Equal(t, "moky", g.Objects[0].Attributes.Label.Value)
},
},
{
name: "var_in_vars",
text: `vars: {

View file

@ -0,0 +1,195 @@
{
"graph": {
"name": "",
"isFolderOnly": false,
"ast": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,0:0:0-9:0:47",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,0:0:0-4:1:27",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,0:0:0-0:4:4",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,0:0:0-0:4:4",
"value": [
{
"string": "vars",
"raw_string": "vars"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,0:6:6-4:1:27",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,1:2:10-3:3:25",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,1:2:10-1:3:11",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,1:2:10-1:3:11",
"value": [
{
"string": "v",
"raw_string": "v"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,1:5:13-3:3:25",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,2:4:19-2:6:21",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,2:4:19-2:6:21",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,2:4:19-2:6:21",
"value": [
{
"string": "ok",
"raw_string": "ok"
}
]
}
}
]
},
"primary": {},
"value": {}
}
}
]
}
}
}
}
]
}
}
}
},
{
"map_key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:0:29-8:1:46",
"key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:0:29-6:1:30",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:0:29-6:1:30",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"primary": {},
"value": {
"block_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:3:32-8:1:46",
"quote": "",
"tag": "md",
"value": "m${v}y"
}
}
}
}
]
},
"root": {
"id": "",
"id_val": "",
"attributes": {
"label": {
"value": ""
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
},
"edges": null,
"objects": [
{
"id": "x",
"id_val": "x",
"references": [
{
"key": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:0:29-6:1:30",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2compiler/TestCompile/var_in_markdown.d2,6:0:29-6:1:30",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": -1
}
],
"attributes": {
"label": {
"value": "m${v}y"
},
"labelDimensions": {
"width": 0,
"height": 0
},
"style": {},
"near_key": null,
"language": "markdown",
"shape": {
"value": "text"
},
"direction": {
"value": ""
},
"constraint": null
},
"zIndex": 0
}
]
},
"err": null
}