# File lib/maruku/output/to_html.rb, line 194
        def to_html_document_tree
                doc = Document.new(nil,{:respect_whitespace =>:all})
        #      doc << XMLDecl.new
                
                root = Element.new('html', doc)
                root.add_namespace('http://www.w3.org/1999/xhtml')
                root.add_namespace('svg', "http://www.w3.org/2000/svg" )
                lang = self.attributes[:lang] || 'en'
                root.attributes['xml:lang'] = lang
                
                root << xml_newline
                head = Element.new 'head', root
                
                        #<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
                        me = Element.new 'meta', head
                        me.attributes['http-equiv'] = 'Content-type'
#                       me.attributes['content'] = 'text/html;charset=utf-8'        
                        me.attributes['content'] = 'application/xhtml+xml;charset=utf-8'     
                
                        METAS.each do |m|
                                if value = self.attributes[m.to_sym]
                                        meta = Element.new 'meta', head
                                        meta.attributes['name'] = m
                                        meta.attributes['content'] = value.to_s
                                end
                        end
                        
                        
                        self.attributes.each do |k,v|
                                if k.to_s =~ /\Ameta-(.*)\Z/
                                        meta = Element.new 'meta', head
                                        meta.attributes['name'] = $1
                                        meta.attributes['content'] = v.to_s
                                end
                        end
                        

                        
                        # Create title element
                        doc_title = self.attributes[:title] || self.attributes[:subject] || ""
                        title = Element.new 'title', head
                                title << Text.new(doc_title)
                                                        
                        add_css_to(head)
                        
                
                root << xml_newline
                
                body = Element.new 'body'
                
                        children_to_html.each do |e|
                                body << e
                        end

                        # render footnotes
                        if @doc.footnotes_order.size > 0
                                body << render_footnotes
                        end
                        
                        # When we are rendering a whole document, we add a signature 
                        # at the bottom. 
                        if get_setting(:maruku_signature)
                                body << maruku_html_signature 
                        end
                        
                root << body
                
                doc
        end