lib/hemingway/build.rb in hemingway-0.0.2 vs lib/hemingway/build.rb in hemingway-0.0.3
- old
+ new
@@ -3,24 +3,31 @@
# 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
- t << " id='" + options[:id] + "'" if options[:id]
- t << " class='" + options[:class] + "'" if options[:class]
- t << " href='" + options[:href] + "'" if options[:href]
+ 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 << "</" + html_attribute + ">" unless options[:close_tag] == false
+ t << "</#{html_attribute}>" 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" => "Δ",
@@ -54,10 +61,101 @@
"\\tau" => "τ",
"\\upsilon" => "υ",
"\\phi" => "φ",
"\\chi" => "χ",
"\\psi" => "ψ",
- "\\omega" => "ω"
+ "\\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
\ No newline at end of file