Module: WNS::LabelPronounciation
- Defined in:
- lib/jekyll-wns/assets/label_pronounciation.rb
Class Method Summary collapse
Class Method Details
.enabled?(doc) ⇒ Boolean
4 5 6 7 8 |
# File 'lib/jekyll-wns/assets/label_pronounciation.rb', line 4 def self.enabled?(doc) wns = doc.site.config["wns"] || {} labels = wns["label_pronounciation"] || [] labels.length > 0 end |
.label_pronounciation!(doc) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/jekyll-wns/assets/label_pronounciation.rb', line 10 def self.label_pronounciation!(doc) wns = doc.site.config["wns"] || {} labels = wns["label_pronounciation"] || [] for i in (0..(labels.length()) - 1) do doc.content = doc.content.gsub(Regexp.new("\b(#{labels[i]["term"]})\b"), "<span aria-label='#{labels[i]["pronounciation"]}'>\\1</span>") end end |