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:
authorHoracio Sanson <horacio@allm.net>2016-11-28 20:41:29 +0300
committerSean McGivern <sean@gitlab.com>2017-01-12 13:04:52 +0300
commitf986b4c4e529f4c2518f0ce37dc9dfcaa2f073a0 (patch)
tree13e60d8ed5cb64be9399516882e8d8e73efffbc8 /lib/gitlab/asciidoc.rb
parent826adaaff876d2b6b5886e6d8133b0d0c2cd4a2d (diff)
Add support for PlantUML diagrams in Asciidoc.
This MR enables rendering of PlantUML diagrams in Asciidoc documents. To add a PlantUML diagram all we need is to include a plantuml block like: ``` [plantuml, id="myDiagram", width="100px", height="100px"] -- bob -> alice : ping alice -> bob : pong -- ``` The plantuml block is substituted by an HTML img element with *src* pointing to an external PlantUML server. This MR also add a PlantUML integration section to the Administrator -> Settings page to configure the PlantUML rendering service and to enable/disable it. Closes: #17603
Diffstat (limited to 'lib/gitlab/asciidoc.rb')
-rw-r--r--lib/gitlab/asciidoc.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb
index fa234284361..0618107e2c3 100644
--- a/lib/gitlab/asciidoc.rb
+++ b/lib/gitlab/asciidoc.rb
@@ -1,5 +1,6 @@
require 'asciidoctor'
require 'asciidoctor/converter/html5'
+require "asciidoctor-plantuml"
module Gitlab
# Parser/renderer for the AsciiDoc format that uses Asciidoctor and filters
@@ -29,6 +30,8 @@ module Gitlab
)
asciidoc_opts[:attributes].unshift(*DEFAULT_ADOC_ATTRS)
+ plantuml_setup
+
html = ::Asciidoctor.convert(input, asciidoc_opts)
html = Banzai.post_process(html, context)
@@ -36,6 +39,15 @@ module Gitlab
html.html_safe
end
+ def self.plantuml_setup
+ Asciidoctor::PlantUml.configure do |conf|
+ conf.url = ApplicationSetting.current.plantuml_url
+ conf.svg_enable = ApplicationSetting.current.plantuml_enabled
+ conf.png_enable = ApplicationSetting.current.plantuml_enabled
+ conf.txt_enable = false
+ end
+ end
+
class Html5Converter < Asciidoctor::Converter::Html5Converter
extend Asciidoctor::Converter::Config