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
|
2019-12-04 20:38:33 +05:30
|
|
|
TAG_CLASS = 'js-render-suggestion'
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
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
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project
|
|
|
|
context[:project]
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|