diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index ebe65a5aa..48bc194bd 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -635,16 +635,16 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co textEl := d2themes.NewThemableElement("text", inlineTheme) textEl.X = labelTL.X + float64(connection.LabelWidth)/2 textEl.Y = labelTL.Y + float64(connection.FontSize) - textEl.Fill = connection.GetFontColor() textEl.ClassName = fontClass textEl.Style = fmt.Sprintf("text-anchor:%s;font-size:%vpx", "middle", connection.FontSize) textEl.Content = RenderText(connection.Label, textEl.X, float64(connection.LabelHeight)) if connection.Link != "" { - textEl.Fill = "blue" - textEl.ClassName += " text-underline" + textEl.ClassName += " text-underline text-link" fmt.Fprintf(writer, ``, svg.EscapeText(connection.Link)) + } else { + textEl.Fill = connection.GetFontColor() } fmt.Fprint(writer, textEl.Render()) @@ -1602,6 +1602,22 @@ func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fon }`, ) + appendOnTrigger( + buf, + source, + []string{ + `text-link`, + }, + ` +.text-link { + fill: blue; +} + +.text-link:visited { + fill: #1a0dab; +}`, + ) + appendOnTrigger( buf, source, diff --git a/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg b/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg index e42f6316c..02016c876 100644 --- a/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg +++ b/e2etests/testdata/txtar/link-on-connections/dagre/sketch.exp.svg @@ -2,6 +2,13 @@ .text-underline { text-decoration: underline; } +.text-link { + fill: blue; +} + +.text-link:visited { + fill: #1a0dab; +} .d2-1855656159 .text-bold { font-family: "d2-1855656159-font-bold"; } @@ -116,7 +123,7 @@ 50.000000%, 100.000000% { opacity: 1; } -}]]>abc https://google.com/root.layers.d +}]]>abc https://google.com/root.layers.d diff --git a/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg b/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg index ccfb2dd57..30126f188 100644 --- a/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg +++ b/e2etests/testdata/txtar/link-on-connections/elk/sketch.exp.svg @@ -2,6 +2,13 @@ .text-underline { text-decoration: underline; } +.text-link { + fill: blue; +} + +.text-link:visited { + fill: #1a0dab; +} .d2-4163031082 .text-bold { font-family: "d2-4163031082-font-bold"; } @@ -116,7 +123,7 @@ 50.000000%, 100.000000% { opacity: 1; } -}]]>abc https://google.com/root.layers.d +}]]>abc https://google.com/root.layers.d