Class: Bidify::HtmlStringBidifier

Inherits:
Bidifier
  • Object
show all
Defined in:
lib/bidify/html_string_bidifier.rb

Overview

Bidifying html input as string

Example Usage

Here’s an example of how to use the class:

bidifier = HtmlStringBidifier.new
bidifier.apply("<p>text</p>")

Instance Method Summary collapse

Methods inherited from Bidifier

#initialize

Constructor Details

This class inherits a constructor from Bidify::Bidifier

Instance Method Details

#apply(html_input) ⇒ String

Applies dir=“auto” to the given html string with default configuration

Parameters:

  • html_string (String)

    a stringified HTML content

Returns:

  • (String)

    Bidified version of the input string



24
25
26
27
28
29
# File 'lib/bidify/html_string_bidifier.rb', line 24

def apply(html_input)
  html_node = Nokogiri::HTML.fragment(html_input)
  bidify_recursively(html_node, { root: true })

  html_node.to_s
end