diff --git a/d2exporter/export.go b/d2exporter/export.go
index d01147af9..501867093 100644
--- a/d2exporter/export.go
+++ b/d2exporter/export.go
@@ -354,6 +354,10 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
if edge.Style.Font != nil {
connection.FontFamily = edge.Style.Font.Value
}
+ if edge.Link != nil {
+ connection.Link = edge.Link.Value
+ connection.PrettyLink = toPrettyLink(edge.Dst.Graph, edge.Link.Value)
+ }
connection.Label = text.Text
connection.LabelWidth = text.Dimensions.Width
connection.LabelHeight = text.Dimensions.Height
diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go
index a0e2c14ad..31cf4f439 100644
--- a/d2renderers/d2svg/d2svg.go
+++ b/d2renderers/d2svg/d2svg.go
@@ -502,6 +502,13 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
opacityStyle = fmt.Sprintf(" style='opacity:%f'", connection.Opacity)
}
+ closingTag := ""
+ if connection.Link != "" {
+ fmt.Fprintf(writer, ``, svg.EscapeText(connection.Link))
+ fmt.Println("Hello")
+ closingTag += ""
+ }
+
classStr := ""
if len(connection.Classes) > 0 {
classStr = fmt.Sprintf(` class="%s"`, strings.Join(connection.Classes, " "))
@@ -649,6 +656,7 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
fmt.Fprint(writer, renderArrowheadLabel(connection, connection.DstLabel.Label, true, inlineTheme))
}
fmt.Fprintf(writer, ``)
+ fmt.Fprintf(writer, "%s", closingTag)
return
}
diff --git a/d2target/d2target.go b/d2target/d2target.go
index fe6eba11f..a2c6d680d 100644
--- a/d2target/d2target.go
+++ b/d2target/d2target.go
@@ -599,6 +599,9 @@ type Connection struct {
LabelPosition string `json:"labelPosition"`
LabelPercentage float64 `json:"labelPercentage"`
+ Link string `json:"link"`
+ PrettyLink string `json:"prettyLink,omitempty"`
+
Route []*geo.Point `json:"route"`
IsCurve bool `json:"isCurve,omitempty"`
diff --git a/e2etests/testdata/txtar/link-on-connections/dagre/board.exp.json b/e2etests/testdata/txtar/link-on-connections/dagre/board.exp.json
new file mode 100644
index 000000000..a8053e9bb
--- /dev/null
+++ b/e2etests/testdata/txtar/link-on-connections/dagre/board.exp.json
@@ -0,0 +1,181 @@
+{
+ "name": "",
+ "isFolderOnly": false,
+ "fontFamily": "SourceSansPro",
+ "shapes": [
+ {
+ "id": "a",
+ "type": "rectangle",
+ "pos": {
+ "x": 0,
+ "y": 0
+ },
+ "width": 85,
+ "height": 66,
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "borderRadius": 0,
+ "fill": "B6",
+ "stroke": "B1",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "https://twitter.com",
+ "prettyLink": "https://twitter.com",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "a",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N1",
+ "italic": false,
+ "bold": true,
+ "underline": false,
+ "labelWidth": 8,
+ "labelHeight": 21,
+ "labelPosition": "INSIDE_MIDDLE_CENTER",
+ "zIndex": 0,
+ "level": 1
+ },
+ {
+ "id": "b",
+ "type": "rectangle",
+ "pos": {
+ "x": 16,
+ "y": 166
+ },
+ "width": 53,
+ "height": 66,
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "borderRadius": 0,
+ "fill": "B6",
+ "stroke": "B1",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "b",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N1",
+ "italic": false,
+ "bold": true,
+ "underline": false,
+ "labelWidth": 8,
+ "labelHeight": 21,
+ "labelPosition": "INSIDE_MIDDLE_CENTER",
+ "zIndex": 0,
+ "level": 1
+ }
+ ],
+ "connections": [
+ {
+ "id": "(a <-> b)[0]",
+ "src": "a",
+ "srcArrow": "triangle",
+ "dst": "b",
+ "dstArrow": "triangle",
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "stroke": "B1",
+ "borderRadius": 10,
+ "label": "",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N2",
+ "italic": true,
+ "bold": false,
+ "underline": false,
+ "labelWidth": 0,
+ "labelHeight": 0,
+ "labelPosition": "",
+ "labelPercentage": 0,
+ "link": "https://google.com",
+ "prettyLink": "https://google.com",
+ "route": [
+ {
+ "x": 42.5,
+ "y": 66
+ },
+ {
+ "x": 42.5,
+ "y": 106
+ },
+ {
+ "x": 42.5,
+ "y": 126
+ },
+ {
+ "x": 42.5,
+ "y": 166
+ }
+ ],
+ "isCurve": true,
+ "animated": false,
+ "tooltip": "",
+ "icon": null,
+ "zIndex": 0
+ }
+ ],
+ "root": {
+ "id": "",
+ "type": "",
+ "pos": {
+ "x": 0,
+ "y": 0
+ },
+ "width": 0,
+ "height": 0,
+ "opacity": 0,
+ "strokeDash": 0,
+ "strokeWidth": 0,
+ "borderRadius": 0,
+ "fill": "N7",
+ "stroke": "",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "",
+ "fontSize": 0,
+ "fontFamily": "",
+ "language": "",
+ "color": "",
+ "italic": false,
+ "bold": false,
+ "underline": false,
+ "labelWidth": 0,
+ "labelHeight": 0,
+ "zIndex": 0,
+ "level": 0
+ }
+}
diff --git a/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg b/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg
new file mode 100644
index 000000000..e4483694c
--- /dev/null
+++ b/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg
@@ -0,0 +1,111 @@
+
\ No newline at end of file
diff --git a/e2etests/testdata/txtar/link-on-connections/elk/board.exp.json b/e2etests/testdata/txtar/link-on-connections/elk/board.exp.json
new file mode 100644
index 000000000..2c842d216
--- /dev/null
+++ b/e2etests/testdata/txtar/link-on-connections/elk/board.exp.json
@@ -0,0 +1,172 @@
+{
+ "name": "",
+ "isFolderOnly": false,
+ "fontFamily": "SourceSansPro",
+ "shapes": [
+ {
+ "id": "a",
+ "type": "rectangle",
+ "pos": {
+ "x": 12,
+ "y": 12
+ },
+ "width": 85,
+ "height": 66,
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "borderRadius": 0,
+ "fill": "B6",
+ "stroke": "B1",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "https://twitter.com",
+ "prettyLink": "https://twitter.com",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "a",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N1",
+ "italic": false,
+ "bold": true,
+ "underline": false,
+ "labelWidth": 8,
+ "labelHeight": 21,
+ "labelPosition": "INSIDE_MIDDLE_CENTER",
+ "zIndex": 0,
+ "level": 1
+ },
+ {
+ "id": "b",
+ "type": "rectangle",
+ "pos": {
+ "x": 28,
+ "y": 148
+ },
+ "width": 53,
+ "height": 66,
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "borderRadius": 0,
+ "fill": "B6",
+ "stroke": "B1",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "b",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N1",
+ "italic": false,
+ "bold": true,
+ "underline": false,
+ "labelWidth": 8,
+ "labelHeight": 21,
+ "labelPosition": "INSIDE_MIDDLE_CENTER",
+ "zIndex": 0,
+ "level": 1
+ }
+ ],
+ "connections": [
+ {
+ "id": "(a <-> b)[0]",
+ "src": "a",
+ "srcArrow": "triangle",
+ "dst": "b",
+ "dstArrow": "triangle",
+ "opacity": 1,
+ "strokeDash": 0,
+ "strokeWidth": 2,
+ "stroke": "B1",
+ "borderRadius": 10,
+ "label": "",
+ "fontSize": 16,
+ "fontFamily": "DEFAULT",
+ "language": "",
+ "color": "N2",
+ "italic": true,
+ "bold": false,
+ "underline": false,
+ "labelWidth": 0,
+ "labelHeight": 0,
+ "labelPosition": "",
+ "labelPercentage": 0,
+ "link": "https://google.com",
+ "prettyLink": "https://google.com",
+ "route": [
+ {
+ "x": 54.5,
+ "y": 78
+ },
+ {
+ "x": 54.5,
+ "y": 148
+ }
+ ],
+ "animated": false,
+ "tooltip": "",
+ "icon": null,
+ "zIndex": 0
+ }
+ ],
+ "root": {
+ "id": "",
+ "type": "",
+ "pos": {
+ "x": 0,
+ "y": 0
+ },
+ "width": 0,
+ "height": 0,
+ "opacity": 0,
+ "strokeDash": 0,
+ "strokeWidth": 0,
+ "borderRadius": 0,
+ "fill": "N7",
+ "stroke": "",
+ "shadow": false,
+ "3d": false,
+ "multiple": false,
+ "double-border": false,
+ "tooltip": "",
+ "link": "",
+ "icon": null,
+ "iconPosition": "",
+ "blend": false,
+ "fields": null,
+ "methods": null,
+ "columns": null,
+ "label": "",
+ "fontSize": 0,
+ "fontFamily": "",
+ "language": "",
+ "color": "",
+ "italic": false,
+ "bold": false,
+ "underline": false,
+ "labelWidth": 0,
+ "labelHeight": 0,
+ "zIndex": 0,
+ "level": 0
+ }
+}
diff --git a/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg b/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg
new file mode 100644
index 000000000..efefa51e2
--- /dev/null
+++ b/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg
@@ -0,0 +1,111 @@
+ab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/e2etests/txtar.txt b/e2etests/txtar.txt
index ad28b43f5..6a7547486 100644
--- a/e2etests/txtar.txt
+++ b/e2etests/txtar.txt
@@ -455,6 +455,7 @@ bob -> alice: The ability to play bridge or\ngolf as if they were games.
◎: |md
◎ foo bar
|
+<<<<<<< HEAD
-- gradient --
style.fill: "radial-gradient(circle, white 0%, #8A2BE2 60%, #4B0082 100%)"
@@ -669,3 +670,16 @@ formula: {
\end{equation}
|
}
+||||||| parent of a468259f1 (html links are working on connections)
+=======
+
+
+-- link-on-connections --
+a: {
+ link: https://twitter.com
+}
+
+a <-> b: {
+ link: https://google.com
+}
+>>>>>>> a468259f1 (html links are working on connections)