# File lib/PageTemplate/parser.rb, line 568
    def parse(body)
      rx = @glossary.directive
      stack = [Template.new(self)]
      stack[0].parent = self
      last = stack.last
      modifier = nil
      closer = nil
      while (m = rx.match(body))
        pre = m.pre_match
        command = m[1..-1].compact.first.strip.gsub(/\s+/,' ')
        body = m.post_match
        
        # Convert all pre-text to a TextCommand
        if (pre && pre.length > 0)
          stack.last.add TextCommand.new(pre)
        end

        # If the command at the top of the stack is a 'Stacker',
        # Does this command modify it? If so, just skip back.
        next if modifier && @glossary.modifies?(modifier,last,command)

        # If it closes, we're done changing this. Pop it off the
        # Stack and add it to the one above it.
        if closer and @glossary.modifies?(closer,last,command)
          cmd = stack.pop
          last = stack.last
          last.add(cmd)
          modifier = last.class.modifier
          closer = last.class.closer
          next
        end

        # Create the command
        cmd = @glossary.lookup(command)
        
        # If it's a stacking command, push it on the stack
        if cmd.is_a?(StackableCommand)
          modifier = cmd.class.modifier
          closer   = cmd.class.closer
          stack.push cmd
          last = cmd
        else
          last.add cmd
        end
      end
      stack.last.add TextCommand.new(body) if body && body.length > 0
      if (stack.length > 1)
        raise ArgumentError, 'Mismatched command closures in template'
      end
      stack[0]
    end