module Hemingway # This is a moronic little class to generate some HTML Tags around # some content. class Build def self.tag(html_attribute, html_content=nil, options={}) String.new.tap do |t| t << "<#{html_attribute}" options.select { |k, v| k != :close_tag }.each do |k, v| t << " #{k}='#{v}'" end t << ">" t << html_content if html_content t << "" unless options[:close_tag] == false end end def self.symbol(symbol) latex_sym_to_html[symbol] end # return the accented character or just the character if no match. def self.accent(character, accent) character_accent_to_html[character] and character_accent_to_html[character][accent] or character end private def self.latex_sym_to_html { "\\Gamma" => "Γ", "\\Delta" => "Δ", "\\Theta" => "Θ", "\\Lambda" => "Λ", "\\Xi" => "Ξ", "\\Pi" => "Π", "\\Sigma" => "Σ", "\\Upsilon" => "Υ", "\\Phi" => "Φ", "\\Psi" => "Ψ", "\\Omega" => "Ω", "\\alpha" => "α", "\\beta" => "β", "\\gamma" => "γ", "\\delta" => "δ", "\\epsilon" => "ε", "\\zeta" => "ζ", "\\eta" => "η", "\\theta" => "θ", "\\iota" => "ι", "\\kappa" => "κ", "\\lambda" => "λ", "\\mu" => "μ", "\\nu" => "ν", "\\xi" => "ξ", "\\pi" => "π", "\\rho" => "ρ", "\\varsigma" => "ς", "\\sigma" => "σ", "\\tau" => "τ", "\\upsilon" => "υ", "\\phi" => "φ", "\\chi" => "χ", "\\psi" => "ψ", "\\omega" => "ω", "\\rightarrow" => "⇒" } end def self.character_accent_to_html { "A" => { "`" => "À", "'" => "Á", "c" => "Â", "~" => "Ã", '"' => "Ä", "r" => "Å" }, "C" => { "c" => "Ç" }, "E" => { "`" => "È", "'" => "É", "c" => "Ê", '"' => "Ë" }, "I" => { "`" => "Ì", "'" => "Í", "c" => "Î", '"' => "Ï" }, "N" => { "~" => "Ñ" }, "O" => { "`" => "Ò", "'" => "Ó", "c" => "Ô", "~" => "Õ", '"' => "Ö" }, "U" => { "`" => "Ù", "'" => "Ú", "c" => "Û", '"' => "Ü" }, "Y" => { "'" => "Ý" }, "a" => { "`" => "à", "'" => "á", "c" => "â", "~" => "ã", '"' => "ä", "r" => "å" }, "c" => { "c" => "ç" }, "e" => { "`" => "è", "'" => "é", "c" => "ê", '"' => "ë" }, "i" => { "`" => "ì", "'" => "í", "c" => "î", '"' => "ï" }, "n" => { "~" => "ñ" }, "o" => { "`" => "ò", "'" => "ó", "c" => "ô", "~" => "õ", '"' => "ö" }, "u" => { "`" => "ù", "'" => "ú", "c" => "û", '"' => "ü" }, "y" => { "'" => "ý", '"' => "ÿ" } } end end end