Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Nov 24, 2024
1 parent a0c4da1 commit a7869de
Show file tree
Hide file tree
Showing 10 changed files with 632 additions and 642 deletions.
3 changes: 3 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

- Composition: links pointing to own board are purged [#2203](https://github.com/terrastruct/d2/pull/2203)
- Syntax: reserved keywords must be unquoted [#2231](https://github.com/terrastruct/d2/pull/2231)
- Latex: Backslashes in Latex blocks do not escape [#2232](https://github.com/terrastruct/d2/pull/2232)
- This is a breaking change. Previously Latex blocks required escaping the backslash. So
for older D2 versions, you should remove the excess backslashes.

#### Bugfixes ⛑️

Expand Down
1 change: 0 additions & 1 deletion d2compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ func (c *compiler) compileLabel(attrs *d2graph.Attributes, f d2ir.Node) {
}
switch attrs.Language {
case "latex":
println("\033[1;31m--- DEBUG:", scalar.ScalarString(), "\033[m")
attrs.Shape.Value = d2target.ShapeText
case "markdown":
rendered, err := textmeasure.RenderMarkdown(scalar.ScalarString())
Expand Down
12 changes: 3 additions & 9 deletions e2etests/stable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,30 +1381,24 @@ c: |md
{
name: "latex",
script: `a: |latex
\\Huge{\\frac{\\alpha g^2}{\\omega^5} e^{[ -0.74\\bigl\\{\\frac{\\omega U_\\omega 19.5}{g}\\bigr\\}^{\\!-4}\\,]}}
\Huge{\frac{\alpha g^2}{\omega^5} e^{[ -0.74\bigl\{\frac{\omega U_\omega 19.5}{g}\bigr\}^{\!-4}\,]}}
|
b: |latex
e = mc^2
|
z: |latex
gibberish\\; math:\\sum_{i=0}^\\infty i^2
gibberish\; math:\sum_{i=0}^\infty i^2
|
z -> a
z -> b
a -> c
b -> c
sugar -> c
c: mixed together
c -> solution: we get
Linear program: {
formula: |latex
\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x
\min_{ \mathclap{\substack{ x \in \mathbb{R}^n \ x \geq 0 \ Ax \leq b }}} c^T x
|
}
`,
Expand Down
26 changes: 10 additions & 16 deletions e2etests/testdata/files/grid_outside_labels.d2
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,55 @@ container: ___________________________________container_________________________

amscd plugin: {
ex: |tex
\\begin{CD} B @>{\\text{very long label}}>> C S^{{\\mathcal{W}}_\\Lambda}\\otimes T @>j>> T\\\\ @VVV V \\end{CD}
\begin{CD} B @>{\text{very long label}}>> C S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\ @VVV V \end{CD}
|
}

braket plugin: {
style.3d: true
ex: |tex
\\bra{a}\\ket{b}
\bra{a}\ket{b}
|
}

cancel plugin: {
ex: |tex
\\cancel{Culture + 5}
\cancel{Culture + 5}
|
}

color plugin: {
icon: https://icons.terrastruct.com/essentials/profits.svg
icon.near: outside-right-center
ex: |tex
\\textcolor{red}{y} = \\textcolor{green}{\\sin} x
\textcolor{red}{y} = \textcolor{green}{\sin} x
|
}

gensymb plugin: {
ex: |tex
\\lambda = 10.6\\,\\micro\\mathrm{m}
\lambda = 10.6\,\micro\mathrm{m}
|
}

mhchem plugin: {
style.multiple: true
ex: |tex
\ce{SO4^2- + Ba^2+ -> BaSO4 v}
|
}

physics plugin: {
ex: |tex
\\var{F[g(x)]}
\\dd(\\cos\\theta)
\var{F[g(x)]}
\dd(\cos\theta)
|
}

multilines: {
ex: |tex
\\displaylines{x = a + b \\\\ y = b + c}
\\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
\displaylines{x = a + b \\ y = b + c}
\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
|
}

asm: {
ex: |latex
\\min_{ \\mathclap{\\substack{ x \\in \\mathbb{R}^n \\ x \\geq 0 \\ Ax \\leq b }}} c^T x
\min_{ \mathclap{\substack{ x \in \mathbb{R}^n \ x \geq 0 \ Ax \leq b }}} c^T x
|
}
}
2 changes: 1 addition & 1 deletion e2etests/testdata/files/grid_with_latex.d2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ y: {
z: {
grid-columns: 2
lim: |latex
\\lim_{h \\rightarrow 0 } \\frac{f(x+h)-f(x)}{h}
\lim_{h \rightarrow 0 } \frac{f(x+h)-f(x)}{h}
|
add: |latex
1 + 1
Expand Down
30 changes: 15 additions & 15 deletions e2etests/testdata/stable/grid_outside_labels/dagre/board.exp.json

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

Loading

0 comments on commit a7869de

Please sign in to comment.