Skip to content

Commit

Permalink
Add div and remove a the default bidifiable tags (#6)
Browse files Browse the repository at this point in the history
* Add div to bidifiable tags and improve tests
* Remove a tag from bidifiable tags
  • Loading branch information
ahangarha authored Jun 25, 2023
1 parent 1c37b30 commit 3e7c1c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/bidify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# bidified_html = Bidify.bidify(regular_html)
module Bidify
@bidifiable_tags = %w[h1 h2 h3 h4 h5 h6 p a ul ol blockquote]
@bidifiable_tags = %w[div h1 h2 h3 h4 h5 h6 p ul ol blockquote]

class << self
###
Expand Down
29 changes: 25 additions & 4 deletions spec/bidify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe 'Bidify' do
describe '.bidify' do
it 'bidifies a simple html' do
it 'bidifies a single paragraph' do
input = '<p>some text</p>'
expected_output = '<p dir="auto">some text</p>'

Expand All @@ -13,9 +13,30 @@
expect(actual_output).to eq expected_output
end

it 'bidifies a html with multiple tags' do
input = '<h1>some text</h1><p>A paragraph</p>'
expected_output = %(<h1 dir="auto">some text</h1><p dir="auto">A paragraph</p>)
it 'bidifies all non-list tags in bidifiable tags list' do
input = <<~HTML
<div>Content</div>
<h1>Content</h1>
<h2>Content</h2>
<h3>Content</h3>
<h4>Content</h4>
<h5>Content</h5>
<h6>Content</h6>
<p>Content</p>
<blockquote>Content</blockquote>
HTML

expected_output = <<~HTML
<div dir="auto">Content</div>
<h1 dir="auto">Content</h1>
<h2 dir="auto">Content</h2>
<h3 dir="auto">Content</h3>
<h4 dir="auto">Content</h4>
<h5 dir="auto">Content</h5>
<h6 dir="auto">Content</h6>
<p dir="auto">Content</p>
<blockquote dir="auto">Content</blockquote>
HTML

actual_output = Bidify.bidify(input)

Expand Down

0 comments on commit 3e7c1c9

Please sign in to comment.