Skip to content

Commit

Permalink
allow underlines for connections
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Feb 15, 2024
1 parent 4c845ed commit da4f626
Show file tree
Hide file tree
Showing 7 changed files with 573 additions and 0 deletions.
3 changes: 3 additions & 0 deletions d2exporter/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
if edge.Style.Bold != nil {
connection.Bold, _ = strconv.ParseBool(edge.Style.Bold.Value)
}
if edge.Style.Underline != nil {
connection.Underline, _ = strconv.ParseBool(edge.Style.Underline.Value)
}
if theme != nil && theme.SpecialRules.Mono {
connection.FontFamily = "mono"
}
Expand Down
3 changes: 3 additions & 0 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
} else if connection.Italic {
fontClass += "-italic"
}
if connection.Underline {
fontClass += " text-underline"
}
if connection.Fill != color.Empty {
rectEl := d2themes.NewThemableElement("rect")
rectEl.X, rectEl.Y = labelTL.X, labelTL.Y
Expand Down
6 changes: 6 additions & 0 deletions e2etests/testdata/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,9 @@ monsters: {
}

costumes.monster -> monsters.id

-- connection-underline --

a -> b: hi {
style.underline: true
}
178 changes: 178 additions & 0 deletions e2etests/testdata/txtar/connection-underline/dagre/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions e2etests/testdata/txtar/connection-underline/dagre/sketch.exp.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da4f626

Please sign in to comment.