2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
# Generated HTML is transformed back to GFM by app/assets/javascripts/behaviors/markdown/nodes/code_block.js
|
2019-02-15 15:39:39 +05:30
|
|
|
module Banzai
|
|
|
|
module Filter
|
|
|
|
class SuggestionFilter < HTML::Pipeline::Filter
|
|
|
|
# Class used for tagging elements that should be rendered
|
|
|
|
TAG_CLASS = 'js-render-suggestion'.freeze
|
|
|
|
|
|
|
|
def call
|
|
|
|
return doc unless suggestions_filter_enabled?
|
|
|
|
|
|
|
|
doc.search('pre.suggestion > code').each do |node|
|
|
|
|
node.add_class(TAG_CLASS)
|
|
|
|
end
|
|
|
|
|
|
|
|
doc
|
|
|
|
end
|
|
|
|
|
|
|
|
def suggestions_filter_enabled?
|
|
|
|
context[:suggestions_filter_enabled]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|