fix importing icon.near field
This commit is contained in:
parent
f188db824f
commit
7363608615
3 changed files with 184 additions and 1 deletions
|
|
@ -2396,6 +2396,16 @@ layers: {
|
|||
}`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/link-board-underscore-not-found.d2:7:9: linked board not found`,
|
||||
},
|
||||
{
|
||||
name: "import-icon-near",
|
||||
text: `y: @y
|
||||
`,
|
||||
files: map[string]string{
|
||||
"y.d2": `syslog
|
||||
*.icon.near: center-left
|
||||
`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "border-radius-negative",
|
||||
text: `x
|
||||
|
|
|
|||
|
|
@ -934,7 +934,7 @@ func (c *compiler) extendLinks(m *Map, importF *Field, importDir string) {
|
|||
s := d2format.Format(kp)
|
||||
f.Primary_.Value = d2ast.MakeValueBox(d2ast.FlatUnquotedString(s)).ScalarBox().Unbox()
|
||||
}
|
||||
if f.Name == "icon" {
|
||||
if f.Name == "icon" && f.Primary() != nil {
|
||||
val := f.Primary().Value.ScalarString()
|
||||
u, err := url.Parse(html.UnescapeString(val))
|
||||
isRemoteImg := err == nil && strings.HasPrefix(u.Scheme, "http")
|
||||
|
|
|
|||
173
testdata/d2compiler/TestCompile/import-icon-near.exp.json
generated
vendored
Normal file
173
testdata/d2compiler/TestCompile/import-icon-near.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-1:0:6",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:5:5",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "y",
|
||||
"raw_string": "y"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"import": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:3:3-0:5:5",
|
||||
"spread": false,
|
||||
"pre": "",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:4:4-0:5:5",
|
||||
"value": [
|
||||
{
|
||||
"string": "y",
|
||||
"raw_string": "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": "y",
|
||||
"id_val": "y",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/import-icon-near.d2,0:0:0-0:1:1",
|
||||
"value": [
|
||||
{
|
||||
"string": "y",
|
||||
"raw_string": "y"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "y"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
{
|
||||
"id": "syslog",
|
||||
"id_val": "syslog",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:6:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile/y.d2,0:0:0-0:6:6",
|
||||
"value": [
|
||||
{
|
||||
"string": "syslog",
|
||||
"raw_string": "syslog"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "syslog"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null,
|
||||
"iconPosition": {
|
||||
"value": "center-left"
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
Loading…
Reference in a new issue