diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 9a1c1d525..b99feeaea 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -12,3 +12,4 @@ - Fixes styles in connections not overriding styles set by globs [#1857](https://github.com/terrastruct/d2/pull/1857) - Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [#1830](https://github.com/terrastruct/d2/pull/1830) - Fixes edge case of bad import syntax crashing using d2 as a library [#1829](https://github.com/terrastruct/d2/pull/1829) +- Fixes `style.fill` not applying to markdown [#1872](https://github.com/terrastruct/d2/pull/1872) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index b36ad0380..6906c4d68 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -1370,7 +1370,9 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape if targetShape.FontSize != textmeasure.MarkdownFontSize { styles = append(styles, fmt.Sprintf("font-size:%vpx", targetShape.FontSize)) } - + if targetShape.Fill != "" && targetShape.Fill != "transparent" { + styles = append(styles, fmt.Sprintf(`background-color:%s`, targetShape.Fill)) + } if !color.IsThemeColor(targetShape.Color) { styles = append(styles, fmt.Sprintf(`color:%s`, targetShape.Color)) } diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 59a58208d..0b8ed4af1 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -1925,7 +1925,7 @@ a line of text and an walk into a bar. | { - style.stroke: darkorange + style.font-color: darkorange } container -> no container @@ -1935,7 +1935,7 @@ they did it in style | no container.style: { - stroke: red + font-color: red fill: "#CEEDEE" } `, diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json index 93b639665..9c152eae3 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -58,7 +58,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "transparent", - "stroke": "darkorange", + "stroke": "N1", "shadow": false, "3d": false, "multiple": false, @@ -75,7 +75,7 @@ "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", - "color": "N1", + "color": "darkorange", "italic": false, "bold": false, "underline": false, @@ -98,7 +98,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "#CEEDEE", - "stroke": "red", + "stroke": "N1", "shadow": false, "3d": false, "multiple": false, @@ -115,7 +115,7 @@ "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", - "color": "N1", + "color": "red", "italic": false, "bold": false, "underline": false, diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg index fec09481b..4a8c6a24d 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg @@ -1,20 +1,20 @@ -container

they did it in style

-

a header

+container

they did it in style

+

a header

a line of text and an

{
 	indented: "block",
@@ -845,7 +845,7 @@
 }
 

walk into a bar.

-
+
diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json index 152457511..3a3f429c3 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -58,7 +58,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "transparent", - "stroke": "darkorange", + "stroke": "N1", "shadow": false, "3d": false, "multiple": false, @@ -75,7 +75,7 @@ "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", - "color": "N1", + "color": "darkorange", "italic": false, "bold": false, "underline": false, @@ -98,7 +98,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "#CEEDEE", - "stroke": "red", + "stroke": "N1", "shadow": false, "3d": false, "multiple": false, @@ -115,7 +115,7 @@ "fontSize": 16, "fontFamily": "DEFAULT", "language": "markdown", - "color": "N1", + "color": "red", "italic": false, "bold": false, "underline": false, diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg index 24bea82fe..4c439878d 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg @@ -1,20 +1,20 @@ -container

they did it in style

-

a header

+container

they did it in style

+

a header

a line of text and an

{
 	indented: "block",
@@ -845,7 +845,7 @@
 }
 

walk into a bar.

-
+