     name: m[1]
     type: 'attribute'
     value: m[2]
+    append: (prev) ->
+      if @level > prev.level
+        prev.setAttribute @name, @value
+        prev
+      else
+        throw new Error()
     write: ->
       throw new Error()
 

    name: s.substring 1
    type: 'element'
    value: null
    write: ->
      attributes = (" #{k}=\"#{v}\"" for k, v of @attributes).join ''
      children = @children.map((i) -> i.write()).join('')

    name: s.substring(1)
    type: 'text'
    value: null
    append: (prev) ->
      if @level > prev.level
        prev.appendChild @
      else if @level is prev.level
        prev.parent.appendChild @
      else if @level < prev.level
        p = prev
        p = p.parent until p.level is @level
        p.parent.appendChild @
      @
    write: ->
      @name

