Commit 22c18a3b authored by Guillaume Grossetie's avatar Guillaume Grossetie

Small optimization return eagerly if Kroki is disabled

parent 19d90a90
...@@ -9,11 +9,13 @@ module Banzai ...@@ -9,11 +9,13 @@ module Banzai
# #
class KrokiFilter < HTML::Pipeline::Filter class KrokiFilter < HTML::Pipeline::Filter
def call def call
return doc unless settings.kroki_enabled
diagram_selectors = ::Gitlab::Kroki.formats(settings) diagram_selectors = ::Gitlab::Kroki.formats(settings)
.map { |diagram_type| %(pre[lang="#{diagram_type}"] > code) } .map { |diagram_type| %(pre[lang="#{diagram_type}"] > code) }
.join(', ') .join(', ')
return doc unless settings.kroki_enabled && doc.at(diagram_selectors) return doc unless doc.at(diagram_selectors)
diagram_format = "svg" diagram_format = "svg"
doc.css(diagram_selectors).each do |node| doc.css(diagram_selectors).each do |node|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment