Skip to content

Commit 2cb1729

Browse files
committed
update format
1 parent 226d6a4 commit 2cb1729

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

d2js/js.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"oss.terrastruct.com/d2/d2format"
1515
"oss.terrastruct.com/d2/d2oracle"
1616
"oss.terrastruct.com/d2/d2parser"
17-
"oss.terrastruct.com/d2/d2target"
1817
"oss.terrastruct.com/d2/lib/urlenc"
1918
)
2019

@@ -128,11 +127,10 @@ type jsObject struct {
128127
}
129128

130129
type jsParseResponse struct {
131-
DSL string `json:"dsl"`
132-
Texts []*d2target.MText `json:"texts"`
133-
ParseError string `json:"parseError"`
134-
UserError string `json:"userError"`
135-
D2Error string `json:"d2Error"`
130+
DSL string `json:"dsl"`
131+
ParseError string `json:"parseError"`
132+
UserError string `json:"userError"`
133+
D2Error string `json:"d2Error"`
136134
}
137135

138136
type blockFS struct{}
@@ -177,11 +175,14 @@ func jsParse(this js.Value, args []js.Value) interface{} {
177175
return string(str)
178176
}
179177

180-
resp := jsParseResponse{
181-
Texts: g.Texts(),
178+
m, err := d2parser.Parse("", strings.NewReader(dsl), nil)
179+
if err != nil {
180+
return err
182181
}
183182

184-
newDSL := d2format.Format(g.AST)
183+
resp := jsParseResponse{}
184+
185+
newDSL := d2format.Format(m)
185186
if dsl != newDSL {
186187
resp.DSL = newDSL
187188
}

0 commit comments

Comments
 (0)