bidify 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c285c4d577dac68ea9c5ccac31db0a7f9e538a9e4d209d325a417692cb1b2386
4
- data.tar.gz: 32aaa78fb00dbb86f7cffec8880c8d4f270c0ece0f08f8d34adbbb3884d721df
3
+ metadata.gz: 869c99f4077d50f88ff976b15ab4106fd15900e45af1bd5673de5255b6cfb8ef
4
+ data.tar.gz: 688dfb1fcab1cbfb627a851951ca80a16479c96c6498b036f3a0e3453441b7f0
5
5
  SHA512:
6
- metadata.gz: 93927a24291b9d0a5a315a157c0d8439e7d4a4611a2046602646f0c7a06f9209e1d0131ea3feb6f74900b3040403503788f7da0f5259e102df8c5162a4a6fb69
7
- data.tar.gz: d1600270358238a32b59542e844ec900b74eef247c408bb3ba21420385fc0eb4754cdd5a2f36a8f0827c10898821653d2094ac409e1ee85c4d3b1765de7d3b09
6
+ metadata.gz: 56b5b3058a06f7fe748796490cf53d940b81257bfa4e7990045d788170082a000c463a2fce8c85a9e1d63eb306d2ff471b95f5091fddd0ed49a2e328aaebd3cc
7
+ data.tar.gz: aa3cdec3d581149a8c57ee692d4bb912eb86adadddbad364ebda35acda25d6c0905eb329b79406adf187f486adef4077ac246c28b73aacbea4b1ac63922c4fdf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bidify (0.0.1)
4
+ bidify (0.1.0)
5
5
  nokogiri (~> 1.14)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Bidify (Ruby)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/bidify.svg)](https://badge.fury.io/rb/bidify)
4
-
5
3
  Bidify helps to add bidirectional text support to HTML documents.
6
4
 
7
5
  The project is in its very early stage of development and its interface or functionality may break from one version to another. Use it with caution.
@@ -11,8 +9,9 @@ The project is in its very early stage of development and its interface or funct
11
9
  ```rb
12
10
  require 'bidify'
13
11
 
14
- html_input = '<div>some content even in nested format</div>'
12
+ html_input = '<p>some content even in nested format</p>'
15
13
  bidified_html = Bidify.bidify(html_input)
14
+ # bidified_html: '<p dir="auto">some content even in nested format</p>'
16
15
  ```
17
16
 
18
17
  ## License
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bidify
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/bidify.rb CHANGED
@@ -8,7 +8,7 @@ require 'nokogiri'
8
8
  #
9
9
  # bidified_html = Bidify.bidify(regular_html)
10
10
  module Bidify
11
- @bidifiable_tags = %w[h1 h2 h3 h4 h5 h6 p a ul ol li blockquote]
11
+ @bidifiable_tags = %w[div h1 h2 h3 h4 h5 h6 p ul ol blockquote]
12
12
 
13
13
  class << self
14
14
  ###
@@ -16,23 +16,16 @@ module Bidify
16
16
  def bidify(input_html)
17
17
  html_node = Nokogiri::HTML.fragment(input_html)
18
18
  bidify_recursively(html_node, { root: true })
19
+
19
20
  html_node.to_s
20
21
  end
21
22
 
22
23
  private
23
24
 
24
25
  def bidify_recursively(html_node, options = {})
25
- return unless html_node.children.count.positive?
26
-
27
- apply_bidi(html_node, options)
28
- end
29
-
30
- def apply_bidi(node, options)
31
26
  seen_the_first_bidifiable_element = false
32
27
 
33
- node.children.each do |child_node|
34
- next if child_node.blank?
35
-
28
+ html_node.children.each do |child_node|
36
29
  bidify_recursively(child_node)
37
30
 
38
31
  if (options[:root] || seen_the_first_bidifiable_element) && @bidifiable_tags.include?(child_node.name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bidify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mostafa Ahangarha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2023-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri