class TextHyphenRails::HtmlHyphenator

Public Class Methods

new(text, lang, options) click to toggle source
Calls superclass method
# File lib/text_hyphen_rails/html_hyphenator.rb, line 5
def initialize(text, lang, options)
  super
  @doc = Nokogiri::HTML.fragment text
end

Public Instance Methods

result() click to toggle source
# File lib/text_hyphen_rails/html_hyphenator.rb, line 10
def result
  @doc.traverse do |n|
    if n.is_a? Nokogiri::XML::Text
      n.content = n.content.gsub regex do |tok|
        hyphenator.visualize(tok, @opts[:hyphen])
      end
    end
  end
  @doc.to_s
end

Private Instance Methods

text_nodes() click to toggle source
# File lib/text_hyphen_rails/html_hyphenator.rb, line 23
def text_nodes
  # broken
  @doc.xpath('//text()')
end