Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/plantuml_filter.rb')
-rw-r--r--lib/banzai/filter/plantuml_filter.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/banzai/filter/plantuml_filter.rb b/lib/banzai/filter/plantuml_filter.rb
index 93370178a61..e67cdc7df12 100644
--- a/lib/banzai/filter/plantuml_filter.rb
+++ b/lib/banzai/filter/plantuml_filter.rb
@@ -5,18 +5,15 @@ require "asciidoctor_plantuml/plantuml"
module Banzai
module Filter
- # HTML that replaces all `code plantuml` tags with PlantUML img tags.
+ # HTML that replaces all `lang plantuml` tags with PlantUML img tags.
#
class PlantumlFilter < HTML::Pipeline::Filter
- CSS = 'pre > code[lang="plantuml"]'
- XPATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze
-
def call
- return doc unless settings.plantuml_enabled? && doc.at_xpath(XPATH)
+ return doc unless settings.plantuml_enabled? && doc.at_xpath(lang_tag)
plantuml_setup
- doc.xpath(XPATH).each do |node|
+ doc.xpath(lang_tag).each do |node|
img_tag = Nokogiri::HTML::DocumentFragment.parse(
Asciidoctor::PlantUml::Processor.plantuml_content(node.content, {}))
node.parent.replace(img_tag)
@@ -27,6 +24,15 @@ module Banzai
private
+ def lang_tag
+ @lang_tag ||=
+ if Feature.enabled?(:use_cmark_renderer)
+ Gitlab::Utils::Nokogiri.css_to_xpath('pre[lang="plantuml"] > code').freeze
+ else
+ Gitlab::Utils::Nokogiri.css_to_xpath('pre > code[lang="plantuml"]').freeze
+ end
+ end
+
def settings
Gitlab::CurrentSettings.current_application_settings
end