From bf2754edfc87c47702cccf6acecebc201f3606ad Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 3 Feb 2025 17:30:53 -0700 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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)