Class: RhetButler::SlideRenderers::Cues

Inherits:
RhetButler::SlideRenderer show all
Defined in:
lib/rhet-butler/slide-renderers/cues.rb

Defined Under Namespace

Classes: XPathExtensions

Instance Method Summary collapse

Methods inherited from RhetButler::SlideRenderer

#configure, #html_class, #normalize_config, optional_config, #positional_options, required_config, #setup_defaults

Methods inherited from YamlType

#check_config_hash, #init_with, #initialize, register, #setup_defaults, #value_from_config

Constructor Details

This class inherits a constructor from RhetButler::YamlType

Instance Method Details

#process(string) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rhet-butler/slide-renderers/cues.rb', line 17

def process(string)
  doc = Nokogiri::HTML::DocumentFragment.parse(string) #may need DocumentFragment::parse
  doc.xpath('.//*/@class[regex(.,"\b\d+\b")]', XPathExtensions).each do |attr|
    attr.value = "rhet-butler item " + attr.value
    attr.value = attr.value.gsub(/\b\d+\b/){|m| "cue-#{m[0]}"}
  end
  doc.to_s
end