Method: MaRuKu::Out::HTML#to_html_document_tree
- Defined in:
- lib/maruku/output/to_html.rb
#to_html_document_tree ⇒ Object
Render to a complete HTML document (returns an HTMLElement document tree)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/maruku/output/to_html.rb', line 156 def to_html_document_tree root = xelem('html') root['xmlns'] = 'http://www.w3.org/1999/xhtml' root['xmlns:svg'] = "http://www.w3.org/2000/svg" root['xml:lang'] = self.attributes[:lang] || 'en' root << xml_newline head = xelem('head') root << head #<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> me = xelem('meta') me['http-equiv'] = 'Content-type' me['content'] = 'application/xhtml+xml;charset=utf-8' head << me %w(description keywords author revised).each do |m| if value = self.attributes[m.to_sym] = xelem('meta') ['name'] = m ['content'] = value.to_s head << end end self.attributes.each do |k,v| if k.to_s =~ /\Ameta-(.*)\z/ = xelem('meta') ['name'] = $1 ['content'] = v.to_s head << end end # Create title element doc_title = self.attributes[:title] || self.attributes[:subject] || "" begin title_content = MaRuKu::HTMLFragment.new(doc_title).to_html rescue title_content = xtext(doc_title) end title = xelem('title') << title_content head << title add_css_to(head) root << xml_newline body = xelem('body') children_to_html.each do |e| body << e.to_s end # render footnotes unless @doc.footnotes_order.empty? body << render_footnotes(@doc) 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 end |