diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index af9855070..7b72d354a 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -6,6 +6,14 @@ import ( func testRegression(t *testing.T) { tcs := []testCase{ + { + // https://github.com/terrastruct/d2/issues/919 + name: "hex-fill", + script: `x: { + style.fill: "#0D32B2" +} +`, + }, { name: "dagre_special_ids", script: ` diff --git a/e2etests/testdata/regression/hex-fill/dagre/board.exp.json b/e2etests/testdata/regression/hex-fill/dagre/board.exp.json new file mode 100644 index 000000000..e845adb1c --- /dev/null +++ b/e2etests/testdata/regression/hex-fill/dagre/board.exp.json @@ -0,0 +1,88 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "rectangle", + "pos": { + "x": 0, + "y": 0 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0D32B2", + "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": "x", + "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": [], + "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/regression/hex-fill/dagre/sketch.exp.svg b/e2etests/testdata/regression/hex-fill/dagre/sketch.exp.svg new file mode 100644 index 000000000..14369948f --- /dev/null +++ b/e2etests/testdata/regression/hex-fill/dagre/sketch.exp.svg @@ -0,0 +1,23 @@ +x + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/hex-fill/elk/board.exp.json b/e2etests/testdata/regression/hex-fill/elk/board.exp.json new file mode 100644 index 000000000..6f464573e --- /dev/null +++ b/e2etests/testdata/regression/hex-fill/elk/board.exp.json @@ -0,0 +1,88 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "rectangle", + "pos": { + "x": 12, + "y": 12 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0D32B2", + "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": "x", + "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": [], + "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/regression/hex-fill/elk/sketch.exp.svg b/e2etests/testdata/regression/hex-fill/elk/sketch.exp.svg new file mode 100644 index 000000000..df727da81 --- /dev/null +++ b/e2etests/testdata/regression/hex-fill/elk/sketch.exp.svg @@ -0,0 +1,23 @@ +x + + + \ No newline at end of file diff --git a/lib/color/color.go b/lib/color/color.go index 10355a0d8..bf82c9fc2 100644 --- a/lib/color/color.go +++ b/lib/color/color.go @@ -8,9 +8,10 @@ import ( "github.com/mazznoer/csscolorparser" ) -var themeColorRegex = regexp.MustCompile(`^N[1-7]|B[1-6]|AA[245]|AB[45]$`) +var themeColorRegex = regexp.MustCompile(`^(N[1-7]|B[1-6]|AA[245]|AB[45])$`) func IsThemeColor(colorString string) bool { + println("\033[1;31m--- DEBUG:", themeColorRegex.Match([]byte(colorString)), colorString, "\033[m") return themeColorRegex.Match([]byte(colorString)) }