blob: 45b259a2faf1bb9b7610f2db75aeb64cd230d43e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# frozen_string_literal: true
module Banzai
module Filter
# HTML filter that sets dir="auto" for RTL languages support
class SetDirectionFilter < HTML::Pipeline::Filter
def call
# select these elements just on top level of the document
doc.xpath('p|h1|h2|h3|h4|h5|h6|ol|ul[not(@class="section-nav")]|blockquote|table').each do |el|
el['dir'] = 'auto'
end
doc
end
end
end
end
|