From 239552cac873c5a3396014d7628e8556c29b4b3c Mon Sep 17 00:00:00 2001 From: Dyllan To <1279360+dyllan-to-you@users.noreply.github.com> Date: Tue, 21 Jan 2025 16:44:57 -0800 Subject: [PATCH 01/11] Add scoop & choco to windows install documentation --- docs/INSTALL.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 45aa3e6af..17eca3bf7 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -209,6 +209,23 @@ under plain Windows. aka Windows Subsystem for Linux if that's what you prefer. Installation is just like any other Linux system. +### Native Package managers + +Some people have created releases for d2 on windows package managers based on the prebuilt releases! + +#### Scoop + +[Scoop](https://scoop.sh/) is a package manager for windows. It can be used to install d2 by running +```sh +scoop install main/d2 +``` + +#### Chocolatey +[Chocolatey](https://chocolatey.org/) is a package manager for windows. It can be used to install d2 by running +```sh +choco install d2 +``` + ## Docker https://hub.docker.com/repository/docker/terrastruct/d2 From f62d745d355a90a2dd07c4fadca4485cfc54014f Mon Sep 17 00:00:00 2001 From: Dyllan To <1279360+dyllan-to-you@users.noreply.github.com> Date: Sun, 26 Jan 2025 02:59:51 -0800 Subject: [PATCH 02/11] Add badges to windows native package manager install instructions --- docs/INSTALL.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 17eca3bf7..1382cc29a 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -16,6 +16,8 @@ You may install `d2` through any of the following methods. - [Windows](#windows) - [Release archives](#release-archives) - [WSL](#wsl) + - [Native Package managers](#native-package-managers) + - [Docker](#docker) - [Coming soon](#coming-soon) @@ -211,17 +213,17 @@ other Linux system. ### Native Package managers -Some people have created releases for d2 on windows package managers based on the prebuilt releases! +The following are community-managed Windows releases of d2 on popular package managers #### Scoop -[Scoop](https://scoop.sh/) is a package manager for windows. It can be used to install d2 by running +[![scoop/d2 badge](https://img.shields.io/scoop/v/d2)](https://scoop.sh/#/apps?q=d2&id=06d1259ce6446dd25dafa1a6c57285159ec927b0) ```sh scoop install main/d2 ``` #### Chocolatey -[Chocolatey](https://chocolatey.org/) is a package manager for windows. It can be used to install d2 by running +[![chocolatey/d2_badge](https://img.shields.io/chocolatey/v/d2)]([https://chocolatey.org/](https://community.chocolatey.org/packages/d2/0.6.6)) ```sh choco install d2 ``` From d6ac9f8f0094b487aae05d2bd92fdf35e6e371ee Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 16:28:07 -0700 Subject: [PATCH 03/11] d2svg: parse connection label fill gradients --- d2renderers/d2svg/d2svg.go | 3 + .../txtar/gradient/dagre/board.exp.json | 23 +-- .../txtar/gradient/dagre/sketch.exp.svg | 171 ++++++++++-------- .../txtar/gradient/elk/board.exp.json | 17 +- .../txtar/gradient/elk/sketch.exp.svg | 171 ++++++++++-------- e2etests/txtar.txt | 2 +- 6 files changed, 207 insertions(+), 180 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index ccce03afb..26bac5e62 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -1906,6 +1906,9 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) { if color.IsGradient(c.Stroke) { defineGradients(buf, c.Stroke) } + if color.IsGradient(c.Fill) { + defineGradients(buf, c.Fill) + } } // Apply hash on IDs for targeting, to be specific for this diagram diff --git a/e2etests/testdata/txtar/gradient/dagre/board.exp.json b/e2etests/testdata/txtar/gradient/dagre/board.exp.json index 4ff7e0a79..35b556c52 100644 --- a/e2etests/testdata/txtar/gradient/dagre/board.exp.json +++ b/e2etests/testdata/txtar/gradient/dagre/board.exp.json @@ -58,7 +58,7 @@ "type": "rectangle", "pos": { "x": 9, - "y": 166 + "y": 187 }, "width": 89, "height": 66, @@ -106,37 +106,38 @@ "opacity": 1, "strokeDash": 0, "strokeWidth": 2, - "stroke": "B1", + "stroke": "red", + "fill": "radial-gradient(#ffffff, #000000)", "borderRadius": 10, - "label": "", + "label": "foobar", "fontSize": 16, "fontFamily": "DEFAULT", "language": "", - "color": "N2", + "color": "red", "italic": true, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", + "labelWidth": 46, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", "labelPercentage": 0, "link": "", "route": [ { "x": 53, - "y": 66 + "y": 65.5 }, { "x": 53, - "y": 106 + "y": 114.30000305175781 }, { "x": 53, - "y": 126 + "y": 138.6999969482422 }, { "x": 53, - "y": 166 + "y": 187.5 } ], "isCurve": true, diff --git a/e2etests/testdata/txtar/gradient/dagre/sketch.exp.svg b/e2etests/testdata/txtar/gradient/dagre/sketch.exp.svg index ea298f1f3..2939c7f01 100644 --- a/e2etests/testdata/txtar/gradient/dagre/sketch.exp.svg +++ b/e2etests/testdata/txtar/gradient/dagre/sketch.exp.svg @@ -1,10 +1,17 @@ - + .d2-1069291522 .fill-N1{fill:#0A0F25;} + .d2-1069291522 .fill-N2{fill:#676C7E;} + .d2-1069291522 .fill-N3{fill:#9499AB;} + .d2-1069291522 .fill-N4{fill:#CFD2DD;} + .d2-1069291522 .fill-N5{fill:#DEE1EB;} + .d2-1069291522 .fill-N6{fill:#EEF1F8;} + .d2-1069291522 .fill-N7{fill:#FFFFFF;} + .d2-1069291522 .fill-B1{fill:#0D32B2;} + .d2-1069291522 .fill-B2{fill:#0D32B2;} + .d2-1069291522 .fill-B3{fill:#E3E9FD;} + .d2-1069291522 .fill-B4{fill:#E3E9FD;} + .d2-1069291522 .fill-B5{fill:#EDF0FD;} + .d2-1069291522 .fill-B6{fill:#F7F8FE;} + .d2-1069291522 .fill-AA2{fill:#4A6FF3;} + .d2-1069291522 .fill-AA4{fill:#EDF0FD;} + .d2-1069291522 .fill-AA5{fill:#F7F8FE;} + .d2-1069291522 .fill-AB4{fill:#EDF0FD;} + .d2-1069291522 .fill-AB5{fill:#F7F8FE;} + .d2-1069291522 .stroke-N1{stroke:#0A0F25;} + .d2-1069291522 .stroke-N2{stroke:#676C7E;} + .d2-1069291522 .stroke-N3{stroke:#9499AB;} + .d2-1069291522 .stroke-N4{stroke:#CFD2DD;} + .d2-1069291522 .stroke-N5{stroke:#DEE1EB;} + .d2-1069291522 .stroke-N6{stroke:#EEF1F8;} + .d2-1069291522 .stroke-N7{stroke:#FFFFFF;} + .d2-1069291522 .stroke-B1{stroke:#0D32B2;} + .d2-1069291522 .stroke-B2{stroke:#0D32B2;} + .d2-1069291522 .stroke-B3{stroke:#E3E9FD;} + .d2-1069291522 .stroke-B4{stroke:#E3E9FD;} + .d2-1069291522 .stroke-B5{stroke:#EDF0FD;} + .d2-1069291522 .stroke-B6{stroke:#F7F8FE;} + .d2-1069291522 .stroke-AA2{stroke:#4A6FF3;} + .d2-1069291522 .stroke-AA4{stroke:#EDF0FD;} + .d2-1069291522 .stroke-AA5{stroke:#F7F8FE;} + .d2-1069291522 .stroke-AB4{stroke:#EDF0FD;} + .d2-1069291522 .stroke-AB5{stroke:#F7F8FE;} + .d2-1069291522 .background-color-N1{background-color:#0A0F25;} + .d2-1069291522 .background-color-N2{background-color:#676C7E;} + .d2-1069291522 .background-color-N3{background-color:#9499AB;} + .d2-1069291522 .background-color-N4{background-color:#CFD2DD;} + .d2-1069291522 .background-color-N5{background-color:#DEE1EB;} + .d2-1069291522 .background-color-N6{background-color:#EEF1F8;} + .d2-1069291522 .background-color-N7{background-color:#FFFFFF;} + .d2-1069291522 .background-color-B1{background-color:#0D32B2;} + .d2-1069291522 .background-color-B2{background-color:#0D32B2;} + .d2-1069291522 .background-color-B3{background-color:#E3E9FD;} + .d2-1069291522 .background-color-B4{background-color:#E3E9FD;} + .d2-1069291522 .background-color-B5{background-color:#EDF0FD;} + .d2-1069291522 .background-color-B6{background-color:#F7F8FE;} + .d2-1069291522 .background-color-AA2{background-color:#4A6FF3;} + .d2-1069291522 .background-color-AA4{background-color:#EDF0FD;} + .d2-1069291522 .background-color-AA5{background-color:#F7F8FE;} + .d2-1069291522 .background-color-AB4{background-color:#EDF0FD;} + .d2-1069291522 .background-color-AB5{background-color:#F7F8FE;} + .d2-1069291522 .color-N1{color:#0A0F25;} + .d2-1069291522 .color-N2{color:#676C7E;} + .d2-1069291522 .color-N3{color:#9499AB;} + .d2-1069291522 .color-N4{color:#CFD2DD;} + .d2-1069291522 .color-N5{color:#DEE1EB;} + .d2-1069291522 .color-N6{color:#EEF1F8;} + .d2-1069291522 .color-N7{color:#FFFFFF;} + .d2-1069291522 .color-B1{color:#0D32B2;} + .d2-1069291522 .color-B2{color:#0D32B2;} + .d2-1069291522 .color-B3{color:#E3E9FD;} + .d2-1069291522 .color-B4{color:#E3E9FD;} + .d2-1069291522 .color-B5{color:#EDF0FD;} + .d2-1069291522 .color-B6{color:#F7F8FE;} + .d2-1069291522 .color-AA2{color:#4A6FF3;} + .d2-1069291522 .color-AA4{color:#EDF0FD;} + .d2-1069291522 .color-AA5{color:#F7F8FE;} + .d2-1069291522 .color-AB4{color:#EDF0FD;} + .d2-1069291522 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker-d2-1069291522);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker-d2-1069291522);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark-d2-1069291522);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker-d2-1069291522);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark-d2-1069291522);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal-d2-1069291522);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal-d2-1069291522);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright-d2-1069291522);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]> @@ -118,8 +125,12 @@ -gradientcolors - + + + +gradientcolors foobar + - + + \ No newline at end of file diff --git a/e2etests/testdata/txtar/gradient/elk/board.exp.json b/e2etests/testdata/txtar/gradient/elk/board.exp.json index 85dab3899..cfeb60cb8 100644 --- a/e2etests/testdata/txtar/gradient/elk/board.exp.json +++ b/e2etests/testdata/txtar/gradient/elk/board.exp.json @@ -58,7 +58,7 @@ "type": "rectangle", "pos": { "x": 20, - "y": 148 + "y": 239 }, "width": 89, "height": 66, @@ -106,19 +106,20 @@ "opacity": 1, "strokeDash": 0, "strokeWidth": 2, - "stroke": "B1", + "stroke": "red", + "fill": "radial-gradient(#ffffff, #000000)", "borderRadius": 10, - "label": "", + "label": "foobar", "fontSize": 16, "fontFamily": "DEFAULT", "language": "", - "color": "N2", + "color": "red", "italic": true, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", + "labelWidth": 46, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", "labelPercentage": 0, "link": "", "route": [ @@ -128,7 +129,7 @@ }, { "x": 65, - "y": 148 + "y": 239 } ], "animated": false, diff --git a/e2etests/testdata/txtar/gradient/elk/sketch.exp.svg b/e2etests/testdata/txtar/gradient/elk/sketch.exp.svg index 3574722eb..b5b9047d3 100644 --- a/e2etests/testdata/txtar/gradient/elk/sketch.exp.svg +++ b/e2etests/testdata/txtar/gradient/elk/sketch.exp.svg @@ -1,10 +1,17 @@ - + .d2-2458666147 .fill-N1{fill:#0A0F25;} + .d2-2458666147 .fill-N2{fill:#676C7E;} + .d2-2458666147 .fill-N3{fill:#9499AB;} + .d2-2458666147 .fill-N4{fill:#CFD2DD;} + .d2-2458666147 .fill-N5{fill:#DEE1EB;} + .d2-2458666147 .fill-N6{fill:#EEF1F8;} + .d2-2458666147 .fill-N7{fill:#FFFFFF;} + .d2-2458666147 .fill-B1{fill:#0D32B2;} + .d2-2458666147 .fill-B2{fill:#0D32B2;} + .d2-2458666147 .fill-B3{fill:#E3E9FD;} + .d2-2458666147 .fill-B4{fill:#E3E9FD;} + .d2-2458666147 .fill-B5{fill:#EDF0FD;} + .d2-2458666147 .fill-B6{fill:#F7F8FE;} + .d2-2458666147 .fill-AA2{fill:#4A6FF3;} + .d2-2458666147 .fill-AA4{fill:#EDF0FD;} + .d2-2458666147 .fill-AA5{fill:#F7F8FE;} + .d2-2458666147 .fill-AB4{fill:#EDF0FD;} + .d2-2458666147 .fill-AB5{fill:#F7F8FE;} + .d2-2458666147 .stroke-N1{stroke:#0A0F25;} + .d2-2458666147 .stroke-N2{stroke:#676C7E;} + .d2-2458666147 .stroke-N3{stroke:#9499AB;} + .d2-2458666147 .stroke-N4{stroke:#CFD2DD;} + .d2-2458666147 .stroke-N5{stroke:#DEE1EB;} + .d2-2458666147 .stroke-N6{stroke:#EEF1F8;} + .d2-2458666147 .stroke-N7{stroke:#FFFFFF;} + .d2-2458666147 .stroke-B1{stroke:#0D32B2;} + .d2-2458666147 .stroke-B2{stroke:#0D32B2;} + .d2-2458666147 .stroke-B3{stroke:#E3E9FD;} + .d2-2458666147 .stroke-B4{stroke:#E3E9FD;} + .d2-2458666147 .stroke-B5{stroke:#EDF0FD;} + .d2-2458666147 .stroke-B6{stroke:#F7F8FE;} + .d2-2458666147 .stroke-AA2{stroke:#4A6FF3;} + .d2-2458666147 .stroke-AA4{stroke:#EDF0FD;} + .d2-2458666147 .stroke-AA5{stroke:#F7F8FE;} + .d2-2458666147 .stroke-AB4{stroke:#EDF0FD;} + .d2-2458666147 .stroke-AB5{stroke:#F7F8FE;} + .d2-2458666147 .background-color-N1{background-color:#0A0F25;} + .d2-2458666147 .background-color-N2{background-color:#676C7E;} + .d2-2458666147 .background-color-N3{background-color:#9499AB;} + .d2-2458666147 .background-color-N4{background-color:#CFD2DD;} + .d2-2458666147 .background-color-N5{background-color:#DEE1EB;} + .d2-2458666147 .background-color-N6{background-color:#EEF1F8;} + .d2-2458666147 .background-color-N7{background-color:#FFFFFF;} + .d2-2458666147 .background-color-B1{background-color:#0D32B2;} + .d2-2458666147 .background-color-B2{background-color:#0D32B2;} + .d2-2458666147 .background-color-B3{background-color:#E3E9FD;} + .d2-2458666147 .background-color-B4{background-color:#E3E9FD;} + .d2-2458666147 .background-color-B5{background-color:#EDF0FD;} + .d2-2458666147 .background-color-B6{background-color:#F7F8FE;} + .d2-2458666147 .background-color-AA2{background-color:#4A6FF3;} + .d2-2458666147 .background-color-AA4{background-color:#EDF0FD;} + .d2-2458666147 .background-color-AA5{background-color:#F7F8FE;} + .d2-2458666147 .background-color-AB4{background-color:#EDF0FD;} + .d2-2458666147 .background-color-AB5{background-color:#F7F8FE;} + .d2-2458666147 .color-N1{color:#0A0F25;} + .d2-2458666147 .color-N2{color:#676C7E;} + .d2-2458666147 .color-N3{color:#9499AB;} + .d2-2458666147 .color-N4{color:#CFD2DD;} + .d2-2458666147 .color-N5{color:#DEE1EB;} + .d2-2458666147 .color-N6{color:#EEF1F8;} + .d2-2458666147 .color-N7{color:#FFFFFF;} + .d2-2458666147 .color-B1{color:#0D32B2;} + .d2-2458666147 .color-B2{color:#0D32B2;} + .d2-2458666147 .color-B3{color:#E3E9FD;} + .d2-2458666147 .color-B4{color:#E3E9FD;} + .d2-2458666147 .color-B5{color:#EDF0FD;} + .d2-2458666147 .color-B6{color:#F7F8FE;} + .d2-2458666147 .color-AA2{color:#4A6FF3;} + .d2-2458666147 .color-AA4{color:#EDF0FD;} + .d2-2458666147 .color-AA5{color:#F7F8FE;} + .d2-2458666147 .color-AB4{color:#EDF0FD;} + .d2-2458666147 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker-d2-2458666147);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker-d2-2458666147);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark-d2-2458666147);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker-d2-2458666147);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark-d2-2458666147);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal-d2-2458666147);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal-d2-2458666147);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright-d2-2458666147);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]> @@ -118,8 +125,12 @@ -gradientcolors - + + + +gradientcolors foobar + - + + \ No newline at end of file diff --git a/e2etests/txtar.txt b/e2etests/txtar.txt index a93f6518d..fae92f88b 100644 --- a/e2etests/txtar.txt +++ b/e2etests/txtar.txt @@ -468,7 +468,7 @@ colors: { style.stroke: "linear-gradient(to right, red, blue, green)" style.font-color: "linear-gradient(to bottom right, red 0%, yellow 25%, green 50%, cyan 75%, blue 100%)" } -gradient -> colors +gradient -> colors: foobar {style.font-color: red; style.stroke: red; style.fill: "radial-gradient(#ffffff, #000000)"} -- var_in_markdown -- vars: { From 59785876954edc36f4d736d4f698ea75dc1f6b5a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 16:40:49 -0700 Subject: [PATCH 04/11] next --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index c3bd1ed13..acbd468c8 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -28,3 +28,4 @@ - Globs: fixes edge case where globs with imported boards would create empty boards [#2247](https://github.com/terrastruct/d2/pull/2247) - Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264) - Null: fixes `null`ing a connection with absolute syntax [#2318](https://github.com/terrastruct/d2/issues/2318) +- Gradients: works with connection fills [#2326](https://github.com/terrastruct/d2/pull/2326) From b27235a4760cc7746cc5ea09fc3009b0c30686dd Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 16:48:59 -0700 Subject: [PATCH 05/11] d2near: constant nears avoid edge routes --- d2layouts/d2near/layout.go | 11 + .../txtar/elk-title-near/dagre/board.exp.json | 503 ++++++++++++++++++ .../txtar/elk-title-near/dagre/sketch.exp.svg | 107 ++++ .../txtar/elk-title-near/elk/board.exp.json | 444 ++++++++++++++++ .../txtar/elk-title-near/elk/sketch.exp.svg | 107 ++++ e2etests/txtar.txt | 12 + 6 files changed, 1184 insertions(+) create mode 100644 e2etests/testdata/txtar/elk-title-near/dagre/board.exp.json create mode 100644 e2etests/testdata/txtar/elk-title-near/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/txtar/elk-title-near/elk/board.exp.json create mode 100644 e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index cfe568d05..eedecd40d 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -190,6 +190,17 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) { } } + for _, edge := range g.Edges { + if edge.Route != nil { + for _, point := range edge.Route { + x1 = math.Min(x1, point.X-pad/2) + y1 = math.Min(y1, point.Y-pad/2) + x2 = math.Max(x2, point.X+pad/2) + y2 = math.Max(y2, point.Y+pad/2) + } + } + } + if math.IsInf(x1, 1) && math.IsInf(x2, -1) { x1 = 0 x2 = 0 diff --git a/e2etests/testdata/txtar/elk-title-near/dagre/board.exp.json b/e2etests/testdata/txtar/elk-title-near/dagre/board.exp.json new file mode 100644 index 000000000..ba19475f6 --- /dev/null +++ b/e2etests/testdata/txtar/elk-title-near/dagre/board.exp.json @@ -0,0 +1,503 @@ +{ + "name": "", + "config": { + "sketch": false, + "themeID": 0, + "darkThemeID": null, + "pad": null, + "center": null, + "layoutEngine": null + }, + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "title", + "type": "rectangle", + "pos": { + "x": -121, + "y": -107 + }, + "width": 408, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "diagram title : Red-line hits 'near: top-center' in elk", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 363, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 10, + "y": 20 + }, + "width": 146, + "height": 292, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "a.a", + "type": "rectangle", + "pos": { + "x": 73, + "y": 50 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "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": 2 + }, + { + "id": "a.b", + "type": "rectangle", + "pos": { + "x": 40, + "y": 216 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "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": 2 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 43, + "y": 452 + }, + "width": 113, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "animated": false, + "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": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b.c", + "type": "rectangle", + "pos": { + "x": 73, + "y": 482 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "c", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "a.(a -> b)[0]", + "src": "a.a", + "srcArrow": "none", + "dst": "a.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": "", + "route": [ + { + "x": 86.5, + "y": 116 + }, + { + "x": 70.5, + "y": 156 + }, + { + "x": 66.5, + "y": 176 + }, + { + "x": 66.5, + "y": 216 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(a.b -> b.c)[0]", + "src": "a.b", + "srcArrow": "none", + "dst": "b.c", + "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": "", + "route": [ + { + "x": 66.5, + "y": 282 + }, + { + "x": 66.5, + "y": 322 + }, + { + "x": 66.5, + "y": 342 + }, + { + "x": 66.5, + "y": 357 + }, + { + "x": 66.5, + "y": 372 + }, + { + "x": 70.5, + "y": 442 + }, + { + "x": 86.5, + "y": 482 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(b.c -> a.a)[0]", + "src": "b.c", + "srcArrow": "none", + "dst": "a.a", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "red", + "fill": "mistyrose", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "red", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 113, + "y": 482 + }, + { + "x": 129, + "y": 442 + }, + { + "x": 133, + "y": 422 + }, + { + "x": 133, + "y": 407 + }, + { + "x": 133, + "y": 392 + }, + { + "x": 133, + "y": 372 + }, + { + "x": 133, + "y": 357 + }, + { + "x": 133, + "y": 342 + }, + { + "x": 133, + "y": 315.3999938964844 + }, + { + "x": 133, + "y": 290.5 + }, + { + "x": 133, + "y": 265.6000061035156 + }, + { + "x": 129, + "y": 156 + }, + { + "x": 113, + "y": 116 + } + ], + "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": "", + "animated": false, + "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/elk-title-near/dagre/sketch.exp.svg b/e2etests/testdata/txtar/elk-title-near/dagre/sketch.exp.svg new file mode 100644 index 000000000..aeefbd124 --- /dev/null +++ b/e2etests/testdata/txtar/elk-title-near/dagre/sketch.exp.svg @@ -0,0 +1,107 @@ +diagram title : Red-line hits 'near: top-center' in elkababc + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json b/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json new file mode 100644 index 000000000..dc901df0c --- /dev/null +++ b/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json @@ -0,0 +1,444 @@ +{ + "name": "", + "config": { + "sketch": false, + "themeID": 0, + "darkThemeID": null, + "pad": null, + "center": null, + "layoutEngine": null + }, + "isFolderOnly": false, + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "title", + "type": "rectangle", + "pos": { + "x": -100, + "y": -84 + }, + "width": 408, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "diagram title : Red-line hits 'near: top-center' in elk", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 363, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 52, + "y": 57 + }, + "width": 153, + "height": 302, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "a.a", + "type": "rectangle", + "pos": { + "x": 102, + "y": 107 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "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": 2 + }, + { + "id": "a.b", + "type": "rectangle", + "pos": { + "x": 102, + "y": 243 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "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": 2 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 52, + "y": 439 + }, + "width": 153, + "height": 166, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "stroke": "B1", + "animated": false, + "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": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b.c", + "type": "rectangle", + "pos": { + "x": 102, + "y": 489 + }, + "width": 53, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "c", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "a.(a -> b)[0]", + "src": "a.a", + "srcArrow": "none", + "dst": "a.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": "", + "route": [ + { + "x": 128.5, + "y": 173 + }, + { + "x": 128.5, + "y": 243 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(a.b -> b.c)[0]", + "src": "a.b", + "srcArrow": "none", + "dst": "b.c", + "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": "", + "route": [ + { + "x": 128.5, + "y": 309 + }, + { + "x": 128.5, + "y": 489 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(b.c -> a.a)[0]", + "src": "b.c", + "srcArrow": "none", + "dst": "a.a", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "red", + "fill": "mistyrose", + "borderRadius": 10, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "red", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 128.5, + "y": 555 + }, + { + "x": 128.5, + "y": 650 + }, + { + "x": 12, + "y": 650 + }, + { + "x": 12, + "y": 12 + }, + { + "x": 128.5, + "y": 12 + }, + { + "x": 128.5, + "y": 107 + } + ], + "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": "", + "animated": false, + "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/elk-title-near/elk/sketch.exp.svg b/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg new file mode 100644 index 000000000..9b5c267d3 --- /dev/null +++ b/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg @@ -0,0 +1,107 @@ +diagram title : Red-line hits 'near: top-center' in elkababc + + + + + + + + \ No newline at end of file diff --git a/e2etests/txtar.txt b/e2etests/txtar.txt index fae92f88b..46e7e9dfe 100644 --- a/e2etests/txtar.txt +++ b/e2etests/txtar.txt @@ -747,3 +747,15 @@ alice -> alice: "Self-messages" alice -> alice: "Self-messages" bob."In the eyes of my dog, I'm a man." + +-- elk-title-near -- +title: "diagram title : Red-line hits 'near: top-center' in elk" {near: top-center} +a: { + a -> b +} +b: { + c +} + +a.b -> b.c +b.c -> a.a: {style.font-color: red; style.stroke: red; style.fill: mistyrose} From 9cff0eeaa6133c934f54779314ed826df231ba87 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 16:50:27 -0700 Subject: [PATCH 06/11] ta --- d2layouts/d2near/layout.go | 11 +- .../txtar/elk-title-near/elk/board.exp.json | 4 +- .../txtar/elk-title-near/elk/sketch.exp.svg | 162 +++++++++--------- 3 files changed, 90 insertions(+), 87 deletions(-) diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index eedecd40d..a08b43ff3 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -191,12 +191,15 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) { } for _, edge := range g.Edges { + if edge.Src.OuterNearContainer() != nil || edge.Dst.OuterNearContainer() != nil { + continue + } if edge.Route != nil { for _, point := range edge.Route { - x1 = math.Min(x1, point.X-pad/2) - y1 = math.Min(y1, point.Y-pad/2) - x2 = math.Max(x2, point.X+pad/2) - y2 = math.Max(y2, point.Y+pad/2) + x1 = math.Min(x1, point.X) + y1 = math.Min(y1, point.Y) + x2 = math.Max(x2, point.X) + y2 = math.Max(y2, point.Y) } } } diff --git a/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json b/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json index dc901df0c..bcfd342a9 100644 --- a/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json +++ b/e2etests/testdata/txtar/elk-title-near/elk/board.exp.json @@ -15,8 +15,8 @@ "id": "title", "type": "rectangle", "pos": { - "x": -100, - "y": -84 + "x": -95, + "y": -74 }, "width": 408, "height": 66, diff --git a/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg b/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg index 9b5c267d3..d1e841ac6 100644 --- a/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg +++ b/e2etests/testdata/txtar/elk-title-near/elk/sketch.exp.svg @@ -1,16 +1,16 @@ -diagram title : Red-line hits 'near: top-center' in elkababc - - + .d2-1173681419 .fill-N1{fill:#0A0F25;} + .d2-1173681419 .fill-N2{fill:#676C7E;} + .d2-1173681419 .fill-N3{fill:#9499AB;} + .d2-1173681419 .fill-N4{fill:#CFD2DD;} + .d2-1173681419 .fill-N5{fill:#DEE1EB;} + .d2-1173681419 .fill-N6{fill:#EEF1F8;} + .d2-1173681419 .fill-N7{fill:#FFFFFF;} + .d2-1173681419 .fill-B1{fill:#0D32B2;} + .d2-1173681419 .fill-B2{fill:#0D32B2;} + .d2-1173681419 .fill-B3{fill:#E3E9FD;} + .d2-1173681419 .fill-B4{fill:#E3E9FD;} + .d2-1173681419 .fill-B5{fill:#EDF0FD;} + .d2-1173681419 .fill-B6{fill:#F7F8FE;} + .d2-1173681419 .fill-AA2{fill:#4A6FF3;} + .d2-1173681419 .fill-AA4{fill:#EDF0FD;} + .d2-1173681419 .fill-AA5{fill:#F7F8FE;} + .d2-1173681419 .fill-AB4{fill:#EDF0FD;} + .d2-1173681419 .fill-AB5{fill:#F7F8FE;} + .d2-1173681419 .stroke-N1{stroke:#0A0F25;} + .d2-1173681419 .stroke-N2{stroke:#676C7E;} + .d2-1173681419 .stroke-N3{stroke:#9499AB;} + .d2-1173681419 .stroke-N4{stroke:#CFD2DD;} + .d2-1173681419 .stroke-N5{stroke:#DEE1EB;} + .d2-1173681419 .stroke-N6{stroke:#EEF1F8;} + .d2-1173681419 .stroke-N7{stroke:#FFFFFF;} + .d2-1173681419 .stroke-B1{stroke:#0D32B2;} + .d2-1173681419 .stroke-B2{stroke:#0D32B2;} + .d2-1173681419 .stroke-B3{stroke:#E3E9FD;} + .d2-1173681419 .stroke-B4{stroke:#E3E9FD;} + .d2-1173681419 .stroke-B5{stroke:#EDF0FD;} + .d2-1173681419 .stroke-B6{stroke:#F7F8FE;} + .d2-1173681419 .stroke-AA2{stroke:#4A6FF3;} + .d2-1173681419 .stroke-AA4{stroke:#EDF0FD;} + .d2-1173681419 .stroke-AA5{stroke:#F7F8FE;} + .d2-1173681419 .stroke-AB4{stroke:#EDF0FD;} + .d2-1173681419 .stroke-AB5{stroke:#F7F8FE;} + .d2-1173681419 .background-color-N1{background-color:#0A0F25;} + .d2-1173681419 .background-color-N2{background-color:#676C7E;} + .d2-1173681419 .background-color-N3{background-color:#9499AB;} + .d2-1173681419 .background-color-N4{background-color:#CFD2DD;} + .d2-1173681419 .background-color-N5{background-color:#DEE1EB;} + .d2-1173681419 .background-color-N6{background-color:#EEF1F8;} + .d2-1173681419 .background-color-N7{background-color:#FFFFFF;} + .d2-1173681419 .background-color-B1{background-color:#0D32B2;} + .d2-1173681419 .background-color-B2{background-color:#0D32B2;} + .d2-1173681419 .background-color-B3{background-color:#E3E9FD;} + .d2-1173681419 .background-color-B4{background-color:#E3E9FD;} + .d2-1173681419 .background-color-B5{background-color:#EDF0FD;} + .d2-1173681419 .background-color-B6{background-color:#F7F8FE;} + .d2-1173681419 .background-color-AA2{background-color:#4A6FF3;} + .d2-1173681419 .background-color-AA4{background-color:#EDF0FD;} + .d2-1173681419 .background-color-AA5{background-color:#F7F8FE;} + .d2-1173681419 .background-color-AB4{background-color:#EDF0FD;} + .d2-1173681419 .background-color-AB5{background-color:#F7F8FE;} + .d2-1173681419 .color-N1{color:#0A0F25;} + .d2-1173681419 .color-N2{color:#676C7E;} + .d2-1173681419 .color-N3{color:#9499AB;} + .d2-1173681419 .color-N4{color:#CFD2DD;} + .d2-1173681419 .color-N5{color:#DEE1EB;} + .d2-1173681419 .color-N6{color:#EEF1F8;} + .d2-1173681419 .color-N7{color:#FFFFFF;} + .d2-1173681419 .color-B1{color:#0D32B2;} + .d2-1173681419 .color-B2{color:#0D32B2;} + .d2-1173681419 .color-B3{color:#E3E9FD;} + .d2-1173681419 .color-B4{color:#E3E9FD;} + .d2-1173681419 .color-B5{color:#EDF0FD;} + .d2-1173681419 .color-B6{color:#F7F8FE;} + .d2-1173681419 .color-AA2{color:#4A6FF3;} + .d2-1173681419 .color-AA4{color:#EDF0FD;} + .d2-1173681419 .color-AA5{color:#F7F8FE;} + .d2-1173681419 .color-AB4{color:#EDF0FD;} + .d2-1173681419 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker-d2-1173681419);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker-d2-1173681419);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark-d2-1173681419);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker-d2-1173681419);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark-d2-1173681419);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal-d2-1173681419);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal-d2-1173681419);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright-d2-1173681419);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]>diagram title : Red-line hits 'near: top-center' in elkababc + + From c210855985523e1c8172448b14ddd5eed2d2e90b Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 17:04:10 -0700 Subject: [PATCH 07/11] next --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index acbd468c8..36069c7a1 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -20,6 +20,7 @@ - Compiler: reserved keywords with missing values error instead of silently doing nothing [#2251](https://github.com/terrastruct/d2/pull/2251) - Render: SVG outputs conform to stricter HTML standards, e.g. no duplicate ids [#2273](https://github.com/terrastruct/d2/issues/2273) - Themes: theme names are consistently cased [#2322](https://github.com/terrastruct/d2/pull/2322) +- Nears: constant nears avoid collision with edge routes [#2327](https://github.com/terrastruct/d2/pull/2327) #### Bugfixes ⛑️ From bf2754edfc87c47702cccf6acecebc201f3606ad Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 17:30:53 -0700 Subject: [PATCH 08/11] d2latex: fix latex backslashes doubling --- d2parser/parse.go | 6 - d2renderers/d2latex/latex.go | 14 + .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 546 +++++++++--------- .../single-backslash-latex/elk/board.exp.json | 2 +- .../single-backslash-latex/elk/sketch.exp.svg | 546 +++++++++--------- 6 files changed, 562 insertions(+), 554 deletions(-) diff --git a/d2parser/parse.go b/d2parser/parse.go index 5d385f210..3eb500484 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -1480,12 +1480,6 @@ func (p *parser) parseBlockString() *d2ast.BlockString { } if r != endHint { - if (bs.Tag == "latex" || bs.Tag == "tex") && r == '\\' { - // For LaTeX, where single backslash is common, we escape it so that users don't have to write double the backslashes - sb.WriteRune('\\') - sb.WriteRune('\\') - continue - } sb.WriteRune(r) continue } diff --git a/d2renderers/d2latex/latex.go b/d2renderers/d2latex/latex.go index 2431a2f0c..640c712b8 100644 --- a/d2renderers/d2latex/latex.go +++ b/d2renderers/d2latex/latex.go @@ -6,6 +6,7 @@ import ( "math" "regexp" "strconv" + "strings" "oss.terrastruct.com/d2/lib/jsrunner" "oss.terrastruct.com/util-go/xdefer" @@ -28,6 +29,7 @@ var svgRe = regexp.MustCompile(`]+width="([0-9\.]+)ex" height="([0-9\.]+) func Render(s string) (_ string, err error) { defer xdefer.Errorf(&err, "latex failed to parse") + s = doubleBackslashes(s) runner := jsrunner.NewJSRunner() if _, err := runner.RunString(polyfillsJS); err != nil { @@ -82,3 +84,15 @@ func Measure(s string) (width, height int, err error) { return int(math.Ceil(wf * float64(pxPerEx))), int(math.Ceil(hf * float64(pxPerEx))), nil } + +func doubleBackslashes(s string) string { + var result strings.Builder + for i := 0; i < len(s); i++ { + if s[i] == '\\' { + result.WriteString("\\\\") + } else { + result.WriteByte(s[i]) + } + } + return result.String() +} diff --git a/e2etests/testdata/txtar/single-backslash-latex/dagre/board.exp.json b/e2etests/testdata/txtar/single-backslash-latex/dagre/board.exp.json index 209ca0af6..ca9c31076 100644 --- a/e2etests/testdata/txtar/single-backslash-latex/dagre/board.exp.json +++ b/e2etests/testdata/txtar/single-backslash-latex/dagre/board.exp.json @@ -81,7 +81,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\begin{equation} \\\\label{eq1}\n\\\\begin{split}\nA & = \\\\frac{\\\\\\\\pi r^2}{2} \\\\\\\\\n & = \\\\frac{1}{2} \\\\pi r^2\n\\\\end{split}\n\\\\end{equation}", + "label": "\\begin{equation} \\label{eq1}\n\\begin{split}\nA & = \\frac{\\\\pi r^2}{2} \\\\\n & = \\frac{1}{2} \\pi r^2\n\\end{split}\n\\end{equation}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/txtar/single-backslash-latex/dagre/sketch.exp.svg b/e2etests/testdata/txtar/single-backslash-latex/dagre/sketch.exp.svg index a7b300871..fceeba7c5 100644 --- a/e2etests/testdata/txtar/single-backslash-latex/dagre/sketch.exp.svg +++ b/e2etests/testdata/txtar/single-backslash-latex/dagre/sketch.exp.svg @@ -1,9 +1,9 @@ -formula +formula diff --git a/e2etests/testdata/txtar/single-backslash-latex/elk/board.exp.json b/e2etests/testdata/txtar/single-backslash-latex/elk/board.exp.json index 6ae60e7aa..56951790c 100644 --- a/e2etests/testdata/txtar/single-backslash-latex/elk/board.exp.json +++ b/e2etests/testdata/txtar/single-backslash-latex/elk/board.exp.json @@ -81,7 +81,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\begin{equation} \\\\label{eq1}\n\\\\begin{split}\nA & = \\\\frac{\\\\\\\\pi r^2}{2} \\\\\\\\\n & = \\\\frac{1}{2} \\\\pi r^2\n\\\\end{split}\n\\\\end{equation}", + "label": "\\begin{equation} \\label{eq1}\n\\begin{split}\nA & = \\frac{\\\\pi r^2}{2} \\\\\n & = \\frac{1}{2} \\pi r^2\n\\end{split}\n\\end{equation}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/txtar/single-backslash-latex/elk/sketch.exp.svg b/e2etests/testdata/txtar/single-backslash-latex/elk/sketch.exp.svg index e753ca5c4..d14630906 100644 --- a/e2etests/testdata/txtar/single-backslash-latex/elk/sketch.exp.svg +++ b/e2etests/testdata/txtar/single-backslash-latex/elk/sketch.exp.svg @@ -1,9 +1,9 @@ -formula +formula From 308df8065ac0274d3d42c8c3026b817a8c45e307 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 17:35:30 -0700 Subject: [PATCH 09/11] ta --- d2renderers/d2latex/latex_test.go | 9 +- .../grid_with_latex/dagre/board.exp.json | 2 +- .../grid_with_latex/dagre/sketch.exp.svg | 552 ++++++++--------- .../grid_with_latex/elk/board.exp.json | 2 +- .../grid_with_latex/elk/sketch.exp.svg | 552 ++++++++--------- .../grid_outside_labels/dagre/board.exp.json | 18 +- .../grid_outside_labels/dagre/sketch.exp.svg | 548 ++++++++--------- .../grid_outside_labels/elk/board.exp.json | 18 +- .../grid_outside_labels/elk/sketch.exp.svg | 548 ++++++++--------- .../stable/latex/dagre/board.exp.json | 6 +- .../stable/latex/dagre/sketch.exp.svg | 558 ++++++++--------- .../testdata/stable/latex/elk/board.exp.json | 6 +- .../testdata/stable/latex/elk/sketch.exp.svg | 558 ++++++++--------- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 572 +++++++++--------- .../elk/board.exp.json | 2 +- .../elk/sketch.exp.svg | 572 +++++++++--------- .../themes/terminal/dagre/board.exp.json | 2 +- .../themes/terminal/dagre/sketch.exp.svg | 570 ++++++++--------- .../themes/terminal/elk/board.exp.json | 2 +- .../themes/terminal/elk/sketch.exp.svg | 570 ++++++++--------- 21 files changed, 2831 insertions(+), 2838 deletions(-) diff --git a/d2renderers/d2latex/latex_test.go b/d2renderers/d2latex/latex_test.go index 54f3f8f7c..c23604825 100644 --- a/d2renderers/d2latex/latex_test.go +++ b/d2renderers/d2latex/latex_test.go @@ -8,7 +8,7 @@ import ( func TestRender(t *testing.T) { txts := []string{ `a + b = c`, - `\\frac{1}{2}`, + `\frac{1}{2}`, `a + b = c `, @@ -24,10 +24,3 @@ func TestRender(t *testing.T) { } } } - -func TestRenderError(t *testing.T) { - _, err := Render(`\frac{1}{2}`) - if err == nil { - t.Fatal("expected to error on invalid latex syntax") - } -} diff --git a/e2etests/testdata/regression/grid_with_latex/dagre/board.exp.json b/e2etests/testdata/regression/grid_with_latex/dagre/board.exp.json index d399ccae5..331bc8b39 100644 --- a/e2etests/testdata/regression/grid_with_latex/dagre/board.exp.json +++ b/e2etests/testdata/regression/grid_with_latex/dagre/board.exp.json @@ -333,7 +333,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\lim_{h \\\\rightarrow 0 } \\\\frac{f(x+h)-f(x)}{h}", + "label": "\\lim_{h \\rightarrow 0 } \\frac{f(x+h)-f(x)}{h}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/regression/grid_with_latex/dagre/sketch.exp.svg b/e2etests/testdata/regression/grid_with_latex/dagre/sketch.exp.svg index 4245bcd89..51cdd3f43 100644 --- a/e2etests/testdata/regression/grid_with_latex/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/grid_with_latex/dagre/sketch.exp.svg @@ -1,16 +1,16 @@ -xyzabab +xyzabab diff --git a/e2etests/testdata/regression/grid_with_latex/elk/board.exp.json b/e2etests/testdata/regression/grid_with_latex/elk/board.exp.json index 97138fac1..18df24845 100644 --- a/e2etests/testdata/regression/grid_with_latex/elk/board.exp.json +++ b/e2etests/testdata/regression/grid_with_latex/elk/board.exp.json @@ -333,7 +333,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\lim_{h \\\\rightarrow 0 } \\\\frac{f(x+h)-f(x)}{h}", + "label": "\\lim_{h \\rightarrow 0 } \\frac{f(x+h)-f(x)}{h}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/regression/grid_with_latex/elk/sketch.exp.svg b/e2etests/testdata/regression/grid_with_latex/elk/sketch.exp.svg index 541cc40c6..ba7dd87f7 100644 --- a/e2etests/testdata/regression/grid_with_latex/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/grid_with_latex/elk/sketch.exp.svg @@ -1,16 +1,16 @@ -xyzabab +xyzabab diff --git a/e2etests/testdata/stable/grid_outside_labels/dagre/board.exp.json b/e2etests/testdata/stable/grid_outside_labels/dagre/board.exp.json index 18c935139..70d9e4ece 100644 --- a/e2etests/testdata/stable/grid_outside_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/grid_outside_labels/dagre/board.exp.json @@ -123,7 +123,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\begin{CD} B @>{\\\\text{very long label}}>> C S^{{\\\\mathcal{W}}_\\\\Lambda}\\\\otimes T @>j>> T\\\\\\\\ @VVV V \\\\end{CD}", + "label": "\\begin{CD} B @>{\\text{very long label}}>> C S^{{\\mathcal{W}}_\\Lambda}\\otimes T @>j>> T\\\\ @VVV V \\end{CD}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -206,7 +206,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\bra{a}\\\\ket{b}", + "label": "\\bra{a}\\ket{b}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -289,7 +289,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\cancel{Culture + 5}", + "label": "\\cancel{Culture + 5}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -384,7 +384,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\textcolor{red}{y} = \\\\textcolor{green}{\\\\sin} x", + "label": "\\textcolor{red}{y} = \\textcolor{green}{\\sin} x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -467,7 +467,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\lambda = 10.6\\\\,\\\\micro\\\\mathrm{m}", + "label": "\\lambda = 10.6\\,\\micro\\mathrm{m}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -550,7 +550,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\ce{SO4^2- + Ba^2+ -> BaSO4 v}", + "label": "\\ce{SO4^2- + Ba^2+ -> BaSO4 v}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -633,7 +633,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\var{F[g(x)]}\n\\\\dd(\\\\cos\\\\theta)", + "label": "\\var{F[g(x)]}\n\\dd(\\cos\\theta)", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -716,7 +716,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -799,7 +799,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\min_{ \\\\mathclap{\\\\substack{ x \\\\in \\\\mathbb{R}^n \\\\ x \\\\geq 0 \\\\ Ax \\\\leq b }}} c^T x", + "label": "\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/stable/grid_outside_labels/dagre/sketch.exp.svg b/e2etests/testdata/stable/grid_outside_labels/dagre/sketch.exp.svg index 4f5ed591b..0e343a1ad 100644 --- a/e2etests/testdata/stable/grid_outside_labels/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/grid_outside_labels/dagre/sketch.exp.svg @@ -1,9 +1,9 @@ -___________________________________container____________________________________amscd plugin +___________________________________container____________________________________amscd plugin -braket plugincancel plugincolor plugingensymb pluginmhchem pluginphysics pluginmultilinesasmµ +braket plugincancel plugincolor plugingensymb pluginmhchem pluginphysics pluginmultilinesasmµ diff --git a/e2etests/testdata/stable/grid_outside_labels/elk/board.exp.json b/e2etests/testdata/stable/grid_outside_labels/elk/board.exp.json index 28f052cbc..43fae785c 100644 --- a/e2etests/testdata/stable/grid_outside_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/grid_outside_labels/elk/board.exp.json @@ -123,7 +123,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\begin{CD} B @>{\\\\text{very long label}}>> C S^{{\\\\mathcal{W}}_\\\\Lambda}\\\\otimes T @>j>> T\\\\\\\\ @VVV V \\\\end{CD}", + "label": "\\begin{CD} B @>{\\text{very long label}}>> C S^{{\\mathcal{W}}_\\Lambda}\\otimes T @>j>> T\\\\ @VVV V \\end{CD}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -206,7 +206,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\bra{a}\\\\ket{b}", + "label": "\\bra{a}\\ket{b}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -289,7 +289,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\cancel{Culture + 5}", + "label": "\\cancel{Culture + 5}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -384,7 +384,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\textcolor{red}{y} = \\\\textcolor{green}{\\\\sin} x", + "label": "\\textcolor{red}{y} = \\textcolor{green}{\\sin} x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -467,7 +467,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\lambda = 10.6\\\\,\\\\micro\\\\mathrm{m}", + "label": "\\lambda = 10.6\\,\\micro\\mathrm{m}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -550,7 +550,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\ce{SO4^2- + Ba^2+ -> BaSO4 v}", + "label": "\\ce{SO4^2- + Ba^2+ -> BaSO4 v}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -633,7 +633,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\var{F[g(x)]}\n\\\\dd(\\\\cos\\\\theta)", + "label": "\\var{F[g(x)]}\n\\dd(\\cos\\theta)", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -716,7 +716,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -799,7 +799,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\min_{ \\\\mathclap{\\\\substack{ x \\\\in \\\\mathbb{R}^n \\\\ x \\\\geq 0 \\\\ Ax \\\\leq b }}} c^T x", + "label": "\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/stable/grid_outside_labels/elk/sketch.exp.svg b/e2etests/testdata/stable/grid_outside_labels/elk/sketch.exp.svg index 2aa2555d7..c5165d29b 100644 --- a/e2etests/testdata/stable/grid_outside_labels/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/grid_outside_labels/elk/sketch.exp.svg @@ -1,9 +1,9 @@ -___________________________________container____________________________________amscd plugin +___________________________________container____________________________________amscd plugin -braket plugincancel plugincolor plugingensymb pluginmhchem pluginphysics pluginmultilinesasmµ +braket plugincancel plugincolor plugingensymb pluginmhchem pluginphysics pluginmultilinesasmµ diff --git a/e2etests/testdata/stable/latex/dagre/board.exp.json b/e2etests/testdata/stable/latex/dagre/board.exp.json index 7dea93ce4..c9f049bb5 100644 --- a/e2etests/testdata/stable/latex/dagre/board.exp.json +++ b/e2etests/testdata/stable/latex/dagre/board.exp.json @@ -39,7 +39,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\Huge{\\\\frac{\\\\alpha g^2}{\\\\omega^5} e^{[ -0.74\\\\bigl\\\\{\\\\frac{\\\\omega U_\\\\omega 19.5}{g}\\\\bigr\\\\}^{\\\\!-4}\\\\,]}}", + "label": "\\Huge{\\frac{\\alpha g^2}{\\omega^5} e^{[ -0.74\\bigl\\{\\frac{\\omega U_\\omega 19.5}{g}\\bigr\\}^{\\!-4}\\,]}}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -121,7 +121,7 @@ "fields": null, "methods": null, "columns": null, - "label": "gibberish\\\\; math:\\\\sum_{i=0}^\\\\infty i^2", + "label": "gibberish\\; math:\\sum_{i=0}^\\infty i^2", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -330,7 +330,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\min_{ \\\\mathclap{\\\\substack{ x \\\\in \\\\mathbb{R}^n \\\\ x \\\\geq 0 \\\\ Ax \\\\leq b }}} c^T x", + "label": "\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/stable/latex/dagre/sketch.exp.svg b/e2etests/testdata/stable/latex/dagre/sketch.exp.svg index 962938e29..544d8c666 100644 --- a/e2etests/testdata/stable/latex/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/latex/dagre/sketch.exp.svg @@ -1,23 +1,23 @@ -mixed togethersugarsolutionLinear program we get +mixed togethersugarsolutionLinear program we get diff --git a/e2etests/testdata/stable/latex/elk/board.exp.json b/e2etests/testdata/stable/latex/elk/board.exp.json index 1554a5ab2..07e486399 100644 --- a/e2etests/testdata/stable/latex/elk/board.exp.json +++ b/e2etests/testdata/stable/latex/elk/board.exp.json @@ -39,7 +39,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\Huge{\\\\frac{\\\\alpha g^2}{\\\\omega^5} e^{[ -0.74\\\\bigl\\\\{\\\\frac{\\\\omega U_\\\\omega 19.5}{g}\\\\bigr\\\\}^{\\\\!-4}\\\\,]}}", + "label": "\\Huge{\\frac{\\alpha g^2}{\\omega^5} e^{[ -0.74\\bigl\\{\\frac{\\omega U_\\omega 19.5}{g}\\bigr\\}^{\\!-4}\\,]}}", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -121,7 +121,7 @@ "fields": null, "methods": null, "columns": null, - "label": "gibberish\\\\; math:\\\\sum_{i=0}^\\\\infty i^2", + "label": "gibberish\\; math:\\sum_{i=0}^\\infty i^2", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", @@ -330,7 +330,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\min_{ \\\\mathclap{\\\\substack{ x \\\\in \\\\mathbb{R}^n \\\\ x \\\\geq 0 \\\\ Ax \\\\leq b }}} c^T x", + "label": "\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/stable/latex/elk/sketch.exp.svg b/e2etests/testdata/stable/latex/elk/sketch.exp.svg index 27b84175e..7933e8af2 100644 --- a/e2etests/testdata/stable/latex/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/latex/elk/sketch.exp.svg @@ -1,23 +1,23 @@ -mixed togethersugarsolutionLinear program we get +mixed togethersugarsolutionLinear program we get diff --git a/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/board.exp.json b/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/board.exp.json index 453623b3b..04b6f024b 100644 --- a/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/board.exp.json +++ b/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/board.exp.json @@ -833,7 +833,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/sketch.exp.svg b/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/sketch.exp.svg index fc2ac4b97..1db1da31e 100644 --- a/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/sketch.exp.svg +++ b/e2etests/testdata/themes/dark_terrastruct_flagship/dagre/sketch.exp.svg @@ -1,41 +1,41 @@ -networkuserapi serverlogsusersidintnamestringemailstringpasswordstringlast_logindatetimeproducts+idint+pricedecimal+skustring+namestring

A tale

@@ -908,7 +908,7 @@     city2 := City{Name: "CityB", Population: 1200000}     tellTale(city1, city2) -}Cell Toweronline portaldata processorsatellitesTRANSMITTERuistorage sendsendsendphone logsmake call accessdisplaypersist +}Cell Toweronline portaldata processorsatellitesTRANSMITTERuistorage sendsendsendphone logsmake call accessdisplaypersist diff --git a/e2etests/testdata/themes/dark_terrastruct_flagship/elk/board.exp.json b/e2etests/testdata/themes/dark_terrastruct_flagship/elk/board.exp.json index 929b4eb55..8069b068f 100644 --- a/e2etests/testdata/themes/dark_terrastruct_flagship/elk/board.exp.json +++ b/e2etests/testdata/themes/dark_terrastruct_flagship/elk/board.exp.json @@ -833,7 +833,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "DEFAULT", "language": "latex", diff --git a/e2etests/testdata/themes/dark_terrastruct_flagship/elk/sketch.exp.svg b/e2etests/testdata/themes/dark_terrastruct_flagship/elk/sketch.exp.svg index 05e64909c..c8f793e80 100644 --- a/e2etests/testdata/themes/dark_terrastruct_flagship/elk/sketch.exp.svg +++ b/e2etests/testdata/themes/dark_terrastruct_flagship/elk/sketch.exp.svg @@ -1,41 +1,41 @@ -networkuserapi serverlogsusersidintnamestringemailstringpasswordstringlast_logindatetimeproducts+idint+pricedecimal+skustring+namestring

A tale

@@ -908,7 +908,7 @@     city2 := City{Name: "CityB", Population: 1200000}     tellTale(city1, city2) -}Cell Toweronline portaldata processorsatellitesTRANSMITTERuistorage sendsendsendphone logsmake call accessdisplaypersist +}Cell Toweronline portaldata processorsatellitesTRANSMITTERuistorage sendsendsendphone logsmake call accessdisplaypersist diff --git a/e2etests/testdata/themes/terminal/dagre/board.exp.json b/e2etests/testdata/themes/terminal/dagre/board.exp.json index 751dde3e8..4f9c2a720 100644 --- a/e2etests/testdata/themes/terminal/dagre/board.exp.json +++ b/e2etests/testdata/themes/terminal/dagre/board.exp.json @@ -837,7 +837,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "mono", "language": "latex", diff --git a/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg b/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg index 74c72775c..a34c985c7 100644 --- a/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg +++ b/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg @@ -1,34 +1,34 @@ - +}]]> @@ -934,7 +934,7 @@     city2 := City{Name: "CityB", Population: 1200000}     tellTale(city1, city2) -}Cell TowerONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE sendSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST +}Cell TowerONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE sendSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST diff --git a/e2etests/testdata/themes/terminal/elk/board.exp.json b/e2etests/testdata/themes/terminal/elk/board.exp.json index ae5ac089c..df77a6d2b 100644 --- a/e2etests/testdata/themes/terminal/elk/board.exp.json +++ b/e2etests/testdata/themes/terminal/elk/board.exp.json @@ -837,7 +837,7 @@ "fields": null, "methods": null, "columns": null, - "label": "\\\\displaylines{x = a + b \\\\\\\\ y = b + c}\n\\\\sum_{k=1}^{n} h_{k} \\\\int_{0}^{1} \\\\bigl(\\\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\\\partial_{k} f(a)\\\\bigr) \\\\,dt", + "label": "\\displaylines{x = a + b \\\\ y = b + c}\n\\sum_{k=1}^{n} h_{k} \\int_{0}^{1} \\bigl(\\partial_{k} f(x_{k-1}+t h_{k} e_{k}) -\\partial_{k} f(a)\\bigr) \\,dt", "fontSize": 16, "fontFamily": "mono", "language": "latex", diff --git a/e2etests/testdata/themes/terminal/elk/sketch.exp.svg b/e2etests/testdata/themes/terminal/elk/sketch.exp.svg index 8a0ff9fd4..9324c9f1e 100644 --- a/e2etests/testdata/themes/terminal/elk/sketch.exp.svg +++ b/e2etests/testdata/themes/terminal/elk/sketch.exp.svg @@ -1,34 +1,34 @@ - +}]]> @@ -934,7 +934,7 @@     city2 := City{Name: "CityB", Population: 1200000}     tellTale(city1, city2) -}Cell TowerONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE sendSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST +}Cell TowerONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE sendSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST From 6815cfdde02f192a9a9064575bf38be857722000 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 17:36:40 -0700 Subject: [PATCH 10/11] next --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 36069c7a1..e2489d66a 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -30,3 +30,4 @@ - Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264) - Null: fixes `null`ing a connection with absolute syntax [#2318](https://github.com/terrastruct/d2/issues/2318) - Gradients: works with connection fills [#2326](https://github.com/terrastruct/d2/pull/2326) +- Latex: fixes backslashes doubling on successive parses [#2328](https://github.com/terrastruct/d2/pull/2328) From 69f4c8f03295239c95c4e5f269ac7905953b8f8a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 18:33:06 -0700 Subject: [PATCH 11/11] fix toc --- docs/INSTALL.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 1382cc29a..cadaee346 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -17,7 +17,6 @@ You may install `d2` through any of the following methods. - [Release archives](#release-archives) - [WSL](#wsl) - [Native Package managers](#native-package-managers) - - [Docker](#docker) - [Coming soon](#coming-soon)