Class: Thredded::HtmlPipeline::SpoilerTagFilter::AfterMarkup

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Includes:
Utils
Defined in:
lib/thredded/html_pipeline/spoiler_tag_filter.rb

Constant Summary collapse

SPOILER_START =
[PLACEHOLDER_START_BLOCK, PLACEHOLDER_START_SPAN].freeze
SPOILER_END =
[PLACEHOLDER_END_BLOCK, PLACEHOLDER_END_SPAN].freeze

Instance Method Summary collapse

Instance Method Details

#callObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/thredded/html_pipeline/spoiler_tag_filter.rb', line 61

def call
  doc.css(".#{PLACEHOLDER_START_CLASS}").each do |placeholder_start|
    process(placeholder_start)
  end
  doc.search('.//text()').each do |node|
    content = +node.content # Unfreeze
    SpoilerTagFilter.spoiler_tags_inverse_replacements.each do |(pattern, replacement)|
      content.gsub! pattern, replacement
    end
    node.content = content
  end
  doc
end