Skip to content

Commit

Permalink
Add including_tags option
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Jul 29, 2023
1 parent 94de491 commit 22b6de7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bidify/bidifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def apply
def configure
@bidifiable_tags = DEFAULT_BIDIFIABLE_TAGS.dup
@bidifiable_tags.concat(TABLE_TAGS) if @options[:with_table_support]
@bidifiable_tags.concat(@options[:including_tags]) if @options.key?(:including_tags)
@bidifiable_tags = @options[:only_tags] if @options.key?(:only_tags)
end

Expand Down
17 changes: 17 additions & 0 deletions spec/html_string_bidifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,21 @@

expect(actual_output).to eq expected_output
end

it 'bidies specified additional tags using `including_tags` option' do
input = <<~HTML
<p>راست left</p>
<xyz>left راست</xyz>
HTML

expected_output = <<~HTML
<p dir="auto">راست left</p>
<xyz dir="auto">left راست</xyz>
HTML

bidifier = Bidify::HtmlStringBidifier.new(including_tags: ['xyz'])
actual_output = bidifier.apply(input)

expect(actual_output).to eq expected_output
end
end

0 comments on commit 22b6de7

Please sign in to comment.