diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 75ccfabe5c..e499d8f861 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -13,3 +13,4 @@ - prevent an object's `near` from targeting a text near a constant. [#1100](https://github.com/terrastruct/d2/pull/1100) - fixes inaccurate bold edge label padding. [#1108](https://github.com/terrastruct/d2/pull/1108) +- Prevents Latex blocks from being uppercased in special themes. [#1111](https://github.com/terrastruct/d2/pull/1111) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 34bc96d42a..a9c3706206 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1305,7 +1305,9 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler } if g.Theme != nil && g.Theme.SpecialRules.CapsLock && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeCode) { - obj.Attributes.Label.Value = strings.ToUpper(obj.Attributes.Label.Value) + if obj.Attributes.Language != "latex" { + obj.Attributes.Label.Value = strings.ToUpper(obj.Attributes.Label.Value) + } } labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily) @@ -1455,7 +1457,9 @@ func (g *Graph) Texts() []*d2target.MText { if obj.Attributes.Label.Value != "" { text := obj.Text() if capsLock && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeCode) { - text.Text = strings.ToUpper(text.Text) + if obj.Attributes.Language != "latex" { + text.Text = strings.ToUpper(text.Text) + } } texts = appendTextDedup(texts, text) } diff --git a/e2etests/testdata/themes/terminal/dagre/board.exp.json b/e2etests/testdata/themes/terminal/dagre/board.exp.json index f6c0822e44..1409b56d9d 100644 --- a/e2etests/testdata/themes/terminal/dagre/board.exp.json +++ b/e2etests/testdata/themes/terminal/dagre/board.exp.json @@ -785,6 +785,46 @@ "labelHeight": 401, "zIndex": 0, "level": 1 + }, + { + "id": "ex", + "type": "text", + "pos": { + "x": 758, + "y": 1031 + }, + "width": 404, + "height": 52, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "N1", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "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", + "fontSize": 16, + "fontFamily": "mono", + "language": "latex", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 404, + "labelHeight": 52, + "zIndex": 0, + "level": 1 } ], "connections": [ @@ -1447,6 +1487,54 @@ "tooltip": "", "icon": null, "zIndex": 0 + }, + { + "id": "(code -> ex)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "ex", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 959.5, + "y": 903 + }, + { + "x": 959.5, + "y": 951.4 + }, + { + "x": 959.5, + "y": 977.1 + }, + { + "x": 959.5, + "y": 1031.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 } ], "root": { diff --git a/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg b/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg index 85ed4e4608..4ffd195534 100644 --- a/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg +++ b/e2etests/testdata/themes/terminal/dagre/sketch.exp.svg @@ -1,31 +1,31 @@ -