Skip to content

Commit

Permalink
fix latex uppercasing
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Mar 30, 2023
1 parent 273f5d3 commit 76cc889
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 193 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,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)
8 changes: 6 additions & 2 deletions d2graph/d2graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
88 changes: 88 additions & 0 deletions e2etests/testdata/themes/terminal/dagre/board.exp.json

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

190 changes: 95 additions & 95 deletions e2etests/testdata/themes/terminal/dagre/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions e2etests/testdata/themes/terminal/elk/board.exp.json

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

190 changes: 95 additions & 95 deletions e2etests/testdata/themes/terminal/elk/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion e2etests/themes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ func main() {
}
|
markdown -> code
markdown -> code -> ex
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
|
`,
},
{
Expand Down

0 comments on commit 76cc889

Please sign in to comment.