Merge pull request #1111 from alixander/fix-themed-latex
fix latex uppercasing
This commit is contained in:
commit
2ad4a8e9cc
7 changed files with 369 additions and 193 deletions
|
|
@ -14,3 +14,4 @@
|
||||||
|
|
||||||
- prevent an object's `near` from targeting a text near a constant. [#1100](https://github.com/terrastruct/d2/pull/1100)
|
- 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)
|
- 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)
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
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)
|
labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily)
|
||||||
|
|
@ -1455,7 +1457,9 @@ func (g *Graph) Texts() []*d2target.MText {
|
||||||
if obj.Attributes.Label.Value != "" {
|
if obj.Attributes.Label.Value != "" {
|
||||||
text := obj.Text()
|
text := obj.Text()
|
||||||
if capsLock && !strings.EqualFold(obj.Attributes.Shape.Value, d2target.ShapeCode) {
|
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)
|
texts = appendTextDedup(texts, text)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
88
e2etests/testdata/themes/terminal/dagre/board.exp.json
generated
vendored
88
e2etests/testdata/themes/terminal/dagre/board.exp.json
generated
vendored
|
|
@ -785,6 +785,46 @@
|
||||||
"labelHeight": 401,
|
"labelHeight": 401,
|
||||||
"zIndex": 0,
|
"zIndex": 0,
|
||||||
"level": 1
|
"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": [
|
"connections": [
|
||||||
|
|
@ -1447,6 +1487,54 @@
|
||||||
"tooltip": "",
|
"tooltip": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"zIndex": 0
|
"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": {
|
"root": {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 99 KiB |
79
e2etests/testdata/themes/terminal/elk/board.exp.json
generated
vendored
79
e2etests/testdata/themes/terminal/elk/board.exp.json
generated
vendored
|
|
@ -785,6 +785,46 @@
|
||||||
"labelHeight": 401,
|
"labelHeight": 401,
|
||||||
"zIndex": 0,
|
"zIndex": 0,
|
||||||
"level": 1
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ex",
|
||||||
|
"type": "text",
|
||||||
|
"pos": {
|
||||||
|
"x": 1105,
|
||||||
|
"y": 909
|
||||||
|
},
|
||||||
|
"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": [
|
"connections": [
|
||||||
|
|
@ -1225,6 +1265,45 @@
|
||||||
"tooltip": "",
|
"tooltip": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"zIndex": 0
|
"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": 1307.8333333333333,
|
||||||
|
"y": 824
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 1307.8333333333333,
|
||||||
|
"y": 909
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"root": {
|
"root": {
|
||||||
|
|
|
||||||
190
e2etests/testdata/themes/terminal/elk/sketch.exp.svg
vendored
190
e2etests/testdata/themes/terminal/elk/sketch.exp.svg
vendored
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 99 KiB |
|
|
@ -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
|
||||||
|
|
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue