update format
This commit is contained in:
parent
3fd9964129
commit
5445e5e0de
1 changed files with 10 additions and 9 deletions
11
d2js/js.go
11
d2js/js.go
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"oss.terrastruct.com/d2/d2format"
|
"oss.terrastruct.com/d2/d2format"
|
||||||
"oss.terrastruct.com/d2/d2oracle"
|
"oss.terrastruct.com/d2/d2oracle"
|
||||||
"oss.terrastruct.com/d2/d2parser"
|
"oss.terrastruct.com/d2/d2parser"
|
||||||
"oss.terrastruct.com/d2/d2target"
|
|
||||||
"oss.terrastruct.com/d2/lib/urlenc"
|
"oss.terrastruct.com/d2/lib/urlenc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -129,7 +128,6 @@ type jsObject struct {
|
||||||
|
|
||||||
type jsParseResponse struct {
|
type jsParseResponse struct {
|
||||||
DSL string `json:"dsl"`
|
DSL string `json:"dsl"`
|
||||||
Texts []*d2target.MText `json:"texts"`
|
|
||||||
ParseError string `json:"parseError"`
|
ParseError string `json:"parseError"`
|
||||||
UserError string `json:"userError"`
|
UserError string `json:"userError"`
|
||||||
D2Error string `json:"d2Error"`
|
D2Error string `json:"d2Error"`
|
||||||
|
|
@ -177,11 +175,14 @@ func jsParse(this js.Value, args []js.Value) interface{} {
|
||||||
return string(str)
|
return string(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := jsParseResponse{
|
m, err := d2parser.Parse("", strings.NewReader(dsl), nil)
|
||||||
Texts: g.Texts(),
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newDSL := d2format.Format(g.AST)
|
resp := jsParseResponse{}
|
||||||
|
|
||||||
|
newDSL := d2format.Format(m)
|
||||||
if dsl != newDSL {
|
if dsl != newDSL {
|
||||||
resp.DSL = newDSL
|
resp.DSL = newDSL
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue