diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/asciidoc.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/asciidoc.rb')
-rw-r--r-- | lib/gitlab/asciidoc.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb index 5cacd7e5983..a9c2dd001cb 100644 --- a/lib/gitlab/asciidoc.rb +++ b/lib/gitlab/asciidoc.rb @@ -2,6 +2,7 @@ require 'asciidoctor' require 'asciidoctor-plantuml' +require 'asciidoctor/extensions/asciidoctor_kroki/extension' require 'asciidoctor/extensions' require 'gitlab/asciidoc/html5_converter' require 'gitlab/asciidoc/mermaid_block_processor' @@ -23,7 +24,14 @@ module Gitlab 'source-highlighter' => 'gitlab-html-pipeline', 'icons' => 'font', 'outfilesuffix' => '.adoc', - 'max-include-depth' => MAX_INCLUDE_DEPTH + 'max-include-depth' => MAX_INCLUDE_DEPTH, + # This feature is disabled because it relies on File#read to read the file. + # If we want to enable this feature we will need to provide a "GitLab compatible" implementation. + # This attribute is typically used to share common config (skinparam...) across all PlantUML diagrams. + # The value can be a path or a URL. + 'kroki-plantuml-include!' => '', + # This feature is disabled because it relies on the local file system to save diagrams retrieved from the Kroki server. + 'kroki-fetch-diagram!' => '' }.freeze def self.path_attrs(path) @@ -48,12 +56,21 @@ module Gitlab extensions = proc do include_processor ::Gitlab::Asciidoc::IncludeProcessor.new(context) block ::Gitlab::Asciidoc::MermaidBlockProcessor + ::Gitlab::Kroki.formats(Gitlab::CurrentSettings).each do |name| + block ::AsciidoctorExtensions::KrokiBlockProcessor, name + end end extra_attrs = path_attrs(context[:requested_path]) asciidoc_opts = { safe: :secure, backend: :gitlab_html5, - attributes: DEFAULT_ADOC_ATTRS.merge(extra_attrs), + attributes: DEFAULT_ADOC_ATTRS + .merge(extra_attrs) + .merge({ + # Define the Kroki server URL from the settings. + # This attribute cannot be overridden from the AsciiDoc document. + 'kroki-server-url' => Gitlab::CurrentSettings.kroki_url + }), extensions: extensions } context[:pipeline] = :ascii_doc |