rename + refactor
This commit is contained in:
parent
9c0f49829a
commit
fdb73c14b2
2 changed files with 4 additions and 6 deletions
|
|
@ -760,8 +760,8 @@ func (mb MapNodeBox) Unbox() MapNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mb MapNodeBox) IsSpecialBoard() bool {
|
func (mb MapNodeBox) IsBoardNode() bool {
|
||||||
if mb.MapKey == nil || mb.MapKey.Key == nil {
|
if mb.MapKey == nil || mb.MapKey.Key == nil || len(mb.MapKey.Key.Path) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch mb.MapKey.Key.Path[0].Unbox().ScalarString() {
|
switch mb.MapKey.Key.Path[0].Unbox().ScalarString() {
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ func (p *printer) _map(m *d2ast.Map) {
|
||||||
stepNodes := []d2ast.MapNodeBox{}
|
stepNodes := []d2ast.MapNodeBox{}
|
||||||
for i := 0; i < len(m.Nodes); i++ {
|
for i := 0; i < len(m.Nodes); i++ {
|
||||||
node := m.Nodes[i]
|
node := m.Nodes[i]
|
||||||
if node.MapKey != nil && node.MapKey.Key != nil {
|
if node.IsBoardNode() {
|
||||||
key := node.MapKey.Key
|
key := node.MapKey.Key
|
||||||
switch key.Path[0].Unbox().ScalarString() {
|
switch key.Path[0].Unbox().ScalarString() {
|
||||||
case "layers":
|
case "layers":
|
||||||
|
|
@ -269,8 +269,6 @@ func (p *printer) _map(m *d2ast.Map) {
|
||||||
scenarioNodes = append(scenarioNodes, node)
|
scenarioNodes = append(scenarioNodes, node)
|
||||||
case "steps":
|
case "steps":
|
||||||
stepNodes = append(stepNodes, node)
|
stepNodes = append(stepNodes, node)
|
||||||
default:
|
|
||||||
nodes = append(nodes, node)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
|
|
@ -309,7 +307,7 @@ func (p *printer) _map(m *d2ast.Map) {
|
||||||
p.sb.WriteString("; ")
|
p.sb.WriteString("; ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.IsFileMap() && nb.IsSpecialBoard() {
|
if m.IsFileMap() && nb.IsBoardNode() {
|
||||||
currString := p.sb.String()
|
currString := p.sb.String()
|
||||||
// if the the character before the special board is not a newline, we add one
|
// if the the character before the special board is not a newline, we add one
|
||||||
if currString[len(currString)-2:] != "\n\n" {
|
if currString[len(currString)-2:] != "\n\n" {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue