Class: CSKitStrongs::Formatters::StrongsHtmlFormatter

Inherits:
StrongsPlainTextFormatter show all
Defined in:
lib/cskit-strongs/formatters/strongs_html_formatter.rb

Constant Summary

Constants inherited from StrongsPlainTextFormatter

CSKitStrongs::Formatters::StrongsPlainTextFormatter::PDF, CSKitStrongs::Formatters::StrongsPlainTextFormatter::RLE

Instance Method Summary collapse

Instance Method Details

#format_annotation(annotation, text) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/cskit-strongs/formatters/strongs_html_formatter.rb', line 7

def format_annotation(annotation, text)
  "<span class='cskit-strongs-word' %{data_attrs} data-definition='%{definition}'>%{text}</span>" % {
    :text => text,
    :definition => "[#{annotation.data.unicode}] #{annotation.data.definition}",
    :data_attrs => [:pronunciation, :translit, :unicode].map do |data_attr|
      value = annotation.data.send(data_attr)
      "data-#{data_attr}='#{value.gsub("'", "&#39;")}'"
    end.join(" ")
  }
end