diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 4623190b4..85a27d860 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1364,8 +1364,8 @@ x -> y: { if len(g.Objects) != 1 { t.Fatal(g.Objects) } - if g.Objects[0].Attributes.Link != "https://google.com" { - t.Fatal(g.Objects[0].Attributes.Link) + if g.Objects[0].Attributes.Link.Value != "https://google.com" { + t.Fatal(g.Objects[0].Attributes.Link.Value) } }, }, @@ -1380,8 +1380,8 @@ x -> y: { if len(g.Objects) != 1 { t.Fatal(g.Objects) } - if g.Objects[0].Attributes.Link != "Overview.Untitled board 7.zzzzz" { - t.Fatal(g.Objects[0].Attributes.Link) + if g.Objects[0].Attributes.Link.Value != "Overview.Untitled board 7.zzzzz" { + t.Fatal(g.Objects[0].Attributes.Link.Value) } }, }, diff --git a/d2exporter/export.go b/d2exporter/export.go index 0237d554a..1dcf55179 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -152,8 +152,12 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { } } - shape.Tooltip = obj.Attributes.Tooltip - shape.Link = obj.Attributes.Link + if obj.Attributes.Tooltip != nil { + shape.Tooltip = obj.Attributes.Tooltip.Value + } + if obj.Attributes.Link != nil { + shape.Link = obj.Attributes.Link.Value + } shape.Icon = obj.Attributes.Icon if obj.IconPosition != nil { shape.IconPosition = *obj.IconPosition @@ -232,7 +236,9 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection connection.Animated, _ = strconv.ParseBool(edge.Attributes.Style.Animated.Value) } - connection.Tooltip = edge.Attributes.Tooltip + if edge.Attributes.Tooltip != nil { + connection.Tooltip = edge.Attributes.Tooltip.Value + } connection.Icon = edge.Attributes.Icon if edge.Attributes.Style.Italic != nil { diff --git a/testdata/d2compiler/TestCompile/path_link.exp.json b/testdata/d2compiler/TestCompile/path_link.exp.json index 9a1cb6fc3..7c96d68c6 100644 --- a/testdata/d2compiler/TestCompile/path_link.exp.json +++ b/testdata/d2compiler/TestCompile/path_link.exp.json @@ -129,7 +129,9 @@ "value": "x" }, "style": {}, - "link": "Overview.Untitled board 7.zzzzz", + "link": { + "value": "Overview.Untitled board 7.zzzzz" + }, "near_key": null, "shape": { "value": "rectangle" diff --git a/testdata/d2compiler/TestCompile/url_link.exp.json b/testdata/d2compiler/TestCompile/url_link.exp.json index b0ebf8a9d..eca980a30 100644 --- a/testdata/d2compiler/TestCompile/url_link.exp.json +++ b/testdata/d2compiler/TestCompile/url_link.exp.json @@ -129,7 +129,9 @@ "value": "x" }, "style": {}, - "link": "https://google.com", + "link": { + "value": "https://google.com" + }, "near_key": null, "shape": { "value": "rectangle"