Diff
diff --git a/cstyle/transformers/banda/main.go b/cstyle/transformers/banda/main.go
index 56cc308..011cefd 100644
--- a/cstyle/transformers/banda/main.go
+++ b/cstyle/transformers/banda/main.go
@@ -21,0 +22 @@ func Init() cstyle.Transformer {
+ before.Parent = n
@@ -28 +29 @@ func Init() cstyle.Transformer {
- before.SetInnerText(ps["::before"]["content"][1 : len(ps["::before"]["content"])-1])
+ before.InnerText = ps["::before"]["content"][1 : len(ps["::before"]["content"])-1]
@@ -31 +32 @@ func Init() cstyle.Transformer {
- n.AppendChild(&before)
+ AppendChild(n, &before)
@@ -33 +34 @@ func Init() cstyle.Transformer {
- n.InsertBefore(&before, n.Children[0])
+ InsertBefore(n, &before, n.Children[0])
@@ -38,0 +40 @@ func Init() cstyle.Transformer {
+ after.Parent = n
@@ -45 +47 @@ func Init() cstyle.Transformer {
- after.SetInnerText(ps["::after"]["content"][1 : len(ps["::after"]["content"])-1])
+ after.InnerText = ps["::after"]["content"][1 : len(ps["::after"]["content"])-1]
@@ -47 +49 @@ func Init() cstyle.Transformer {
- n.AppendChild(&after)
+ AppendChild(n, &after)
@@ -54,0 +57,21 @@ func Init() cstyle.Transformer {
+func InsertBefore(n, c, tgt *element.Node) {
+ c.Properties.Id = element.GenerateUniqueId(n, c.TagName())
+ nodeIndex := -1
+ for i, v := range n.Children {
+ if v.Properties.Id == tgt.Properties.Id {
+ nodeIndex = i
+ break
+ }
+ }
+
+ if nodeIndex > 0 {
+ n.Children = append(n.Children[:nodeIndex], append([]*element.Node{c}, n.Children[nodeIndex:]...)...)
+ } else {
+ n.Children = append([]*element.Node{c}, n.Children...)
+ }
+}
+
+func AppendChild(n, c *element.Node) {
+ c.Properties.Id = element.GenerateUniqueId(n, c.TagName())
+ n.Children = append(n.Children, c)
+}