Class: Banzai::Filter::SetDirectionFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Includes:
Concerns::PipelineTimingCheck
Defined in:
lib/banzai/filter/set_direction_filter.rb

Overview

HTML filter that sets dir=“auto” for RTL languages support

Constant Summary

Constants included from Concerns::PipelineTimingCheck

Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS

Instance Method Summary collapse

Methods included from Concerns::PipelineTimingCheck

#exceeded_pipeline_max?

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
# File 'lib/banzai/filter/set_direction_filter.rb', line 9

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