Class: TextHyphenRails::HtmlHyphenator
- Inherits:
-
Hyphenator
- Object
- Hyphenator
- TextHyphenRails::HtmlHyphenator
- Defined in:
- lib/text_hyphen_rails/html_hyphenator.rb
Instance Method Summary collapse
-
#initialize(text, lang, options) ⇒ HtmlHyphenator
constructor
A new instance of HtmlHyphenator.
- #result ⇒ Object
Constructor Details
#initialize(text, lang, options) ⇒ HtmlHyphenator
Returns a new instance of HtmlHyphenator.
5 6 7 8 |
# File 'lib/text_hyphen_rails/html_hyphenator.rb', line 5 def initialize(text, lang, ) super @doc = Nokogiri::HTML.fragment text end |
Instance Method Details
#result ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# 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 |