New Upstream Snapshot - ruby-asciidoctor-plantuml

Ready changes

Summary

Merged new upstream version: 0.1.1+git20221208.1.6a72d7a (was: 0.0.16).

Resulting package

Built on 2023-01-11T04:45 (took 6m1s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-asciidoctor-plantuml

Lintian Result

Diff

diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..09fcb70
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,29 @@
+---
+AllCops:
+  NewCops: enable
+  TargetRubyVersion: 2.6
+
+Naming/FileName:
+  Enabled: true
+  Exclude:
+    - lib/asciidoctor-plantuml.rb
+
+Metrics/MethodLength:
+  Max: 50
+
+Metrics/ClassLength:
+  Max: 250
+  Exclude:
+    - test/test_plantuml.rb
+
+Metrics/AbcSize:
+  Max: 30
+
+Style/FrozenStringLiteralComment:
+  Enabled: false
+
+Style/StringConcatenation:
+  Enabled: false
+
+Layout/LineLength:
+  Max: 120
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..851fabc
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,2 @@
+source 'https://rubygems.org'
+gemspec
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..a7f9227
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,53 @@
+PATH
+  remote: .
+  specs:
+    asciidoctor-plantuml (0.1.1)
+      asciidoctor (>= 2.0.17, < 3.0.0)
+
+GEM
+  remote: https://rubygems.org/
+  specs:
+    asciidoctor (2.0.17)
+    ast (2.4.2)
+    mini_portile2 (2.8.0)
+    nokogiri (1.13.10)
+      mini_portile2 (~> 2.8.0)
+      racc (~> 1.4)
+    parallel (1.22.1)
+    parser (3.1.2.0)
+      ast (~> 2.4.1)
+    power_assert (2.0.1)
+    racc (1.6.1)
+    rainbow (3.1.1)
+    rake (13.0.6)
+    regexp_parser (2.3.1)
+    rexml (3.2.5)
+    rubocop (1.28.2)
+      parallel (~> 1.10)
+      parser (>= 3.1.0.0)
+      rainbow (>= 2.2.2, < 4.0)
+      regexp_parser (>= 1.8, < 3.0)
+      rexml
+      rubocop-ast (>= 1.17.0, < 2.0)
+      ruby-progressbar (~> 1.7)
+      unicode-display_width (>= 1.4.0, < 3.0)
+    rubocop-ast (1.17.0)
+      parser (>= 3.1.1.0)
+    ruby-progressbar (1.11.0)
+    test-unit (3.5.3)
+      power_assert
+    unicode-display_width (2.1.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  asciidoctor-plantuml!
+  bundler (~> 2.2)
+  nokogiri (~> 1.13.6)
+  rake (~> 13.0)
+  rubocop (~> 1.28)
+  test-unit (~> 3.5)
+
+BUNDLED WITH
+   2.2.27
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..4f75c0a
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,22 @@
+Copyright (c) 2014 Pepijn Van Eeckhoudt
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.adoc b/README.adoc
new file mode 100644
index 0000000..7e57f55
--- /dev/null
+++ b/README.adoc
@@ -0,0 +1,155 @@
+= Asciidoctor Plantuml Extension
+Horacio Sanson <https://github.com/hsanson/asciidoctor-diagram>
+:description: README for the Asciidoctor PlantUml extension for Asciidoctor.
+:uri-plantuml: http://plantuml.com
+:uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
+:uri-asciidoctor-diagram: https://github.com/asciidoctor/asciidoctor-diagram
+
+ifdef::env-github[]
+image:https://github.com/hsanson/asciidoctor-plantuml/actions/workflows/ruby.yml/badge.svg[Tests, link=https://github.com/hsanson/asciidoctor-plantuml/actions/workflows/ruby.yml]
+image:https://img.shields.io/gem/v/asciidoctor-plantuml.svg?style=flat[Latest Release, link=https://rubygems.org/gems/asciidoctor-plantuml]
+endif::[]
+
+Asciidoctor PlantUml is an extension that enables you to add
+{uri-plantuml}[PlantUML] diagrams to your AsciiDoc documents.
+
+This extension differs from others like {uri-asciidoctor-diagram}[Asciidoctor
+Diagram] and {uri-py-plantuml}[AsciiDoc PlantUML filter] in that this extension
+does not include PlantUML jar files. Instead it depends on the availability of
+an external PlantUML server.
+
+== Installation
+
+Asciidoctor PlantUml is a RubyGem and can be installed via `gem` or `bundle`
+commands:
+
+    $ gem install asciidoctor-plantuml
+
+== Creating a diagram
+
+A diagram is written inside an open block inside any asciidoc file:
+
+----
+[plantuml, format="png", id="myId"]
+----
+alice -> bob : hello
+bob -> alice : hello
+----
+----
+
+NOTE: You can omit the @startuml/@enduml delimiters. The extension adds them if missing.
+
+TIP: You can create any diagram type supported by PlantUML: sequence, usecase, class, activity, etc.
+
+WARNING: You must use an open block, that is delimited by two *-* instead of four as in a literal block.
+
+The above example is substituted by the following HTML snippet when processed by
+this extension:
+
+[source, html]
+----
+<img id="myId" class="plantuml" src="http://localhost:8080/png/S3dx3fjsaso3d" />
+----
+
+=== PlantUML Server
+
+By default the image source follows the following URL pattern:
+
+.PlantUML URL Pattern
+----
+<server base uri>/<format>/<encoded diagram>
+----
+
+The *<server base uri>* by defaults is *http://localhost:8080/plantuml* and can
+be changed using the following code:
+
+[source,ruby]
+----
+require "asciidoctor-plantuml"
+
+Asciidoctor::PlantUml.configure do |conf|
+  conf.url = "http://my-private-server:8080"
+end
+----
+
+In 2020 the plantuml.com server changed the URL encoding.
+Now you'll need to add a small string to signal the encoding.
+You can enable the new behavior like this:
+
+[source,ruby]
+----
+require "asciidoctor-plantuml"
+
+Asciidoctor::PlantUml.configure do |conf|
+  conf.url = "https://www.plantuml.com"
+  conf.encoding = 'deflate'
+end
+----
+
+The *<format>* is taken from the block format attribute. It defaults to *png*
+and can take any of *png*, *txt* and *svg*.
+
+The *<encoded diagram>* is generated automatically by this extension.
+This is the diagram string compressed and encoded in a format that the PlantUML
+server understands.
+
+=== Diagram Attributes
+
+There are some attributes you can add to the block to customize how the diagram
+is displayed:
+
+  - id: Sets the id attribute of the img element.
+  - alt: Sets the alt attribute of the img element.
+  - width: Sets the width attribute of the img element.
+  - height: Sets the height attribute of the img element.
+  - format: Sets the format of the generated image. Can be either png, svg or
+    txt.
+
+== Using Asciidoctor Cli
+
+To load the asciidoctor-plantuml extension when using the asciidoctor command
+line tool you can use the `-r` flag:
+
+    asciidoctor -r asciidoctor-plantuml sample.adoc
+
+If you want to change the default PlantUML server you can use *PLANTUML_URL*
+environment variables:
+
+    PLANTUML_URL="https://my-private-server:80/" asciidoctor -r asciidoctor-plantuml sample.adoc
+
+
+== Installing PlantUML Server
+
+=== Docker
+
+The simplest way to start a PlantUML server is using docker:
+
+    docker run -d --name plantuml -p 8081:8080 plantuml/plantuml-server:jetty
+
+=== Source
+
+In Ubuntu first you need to create a plantuml.war file from the source code:
+
+[source,bash]
+----
+sudo apt-get install tomcat7 graphviz openjdk-7-jdk git-core maven
+git clone https://github.com/plantuml/plantuml-server.git
+cd plantuml-server
+mvn package
+----
+
+Then copy the *plantuml.war* file generated when building the package (mvn package) to the Tomcat applications folder:
+
+
+[source,bash]
+----
+sudo cp plantuml.war /var/lib/tomcat7/webapps/plantuml.war
+sudo chown tomcat7:tomcat7 /usr/share/jetty/webapps/plantuml.war
+sudo service restart tomcat7
+----
+
+After restarting Tomcat the application will be running on the server port 8080.
+You can change the port and other parameters in the */etc/tomcat7/server.xml* file.
+
+You may also need to set the JAVA_HOME variable in the */etc/defaults/tomcat7*
+file if you have the java runtime in a non-standard place.
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..cf4652f
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,8 @@
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+  t.libs << 'test'
+end
+
+desc 'Run tests'
+task default: :test
diff --git a/asciidoctor-plantuml.gemspec b/asciidoctor-plantuml.gemspec
index c99a633..bdd91c3 100644
--- a/asciidoctor-plantuml.gemspec
+++ b/asciidoctor-plantuml.gemspec
@@ -1,45 +1,31 @@
-#########################################################
-# This file has been automatically generated by gem2tgz #
-#########################################################
-# -*- encoding: utf-8 -*-
-# stub: asciidoctor-plantuml 0.0.16 ruby lib
+# frozen_string_literal: true
 
-Gem::Specification.new do |s|
-  s.name = "asciidoctor-plantuml".freeze
-  s.version = "0.0.16"
+lib = File.expand_path('lib', __dir__)
+$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+require 'asciidoctor_plantuml/version'
 
-  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
-  s.metadata = { "rubygems_mfa_required" => "true" } if s.respond_to? :metadata=
-  s.require_paths = ["lib".freeze]
-  s.authors = ["Horacio Sanson".freeze]
-  s.date = "2022-04-30"
-  s.description = "Asciidoctor PlantUML extension".freeze
-  s.email = ["hsanson@gmail.com".freeze]
-  s.files = ["lib/asciidoctor-plantuml.rb".freeze, "lib/asciidoctor_plantuml/plantuml.rb".freeze, "lib/asciidoctor_plantuml/version.rb".freeze, "test/test_plantuml.rb".freeze]
-  s.homepage = "https://github.com/hsanson/asciidoctor-plantuml".freeze
-  s.licenses = ["MIT".freeze]
-  s.required_ruby_version = Gem::Requirement.new(">= 2.6".freeze)
-  s.rubygems_version = "3.3.15".freeze
-  s.summary = "Asciidoctor support for PlantUML diagrams.".freeze
-  s.test_files = ["test/test_plantuml.rb".freeze]
+Gem::Specification.new do |s|
+  s.name = 'asciidoctor-plantuml'
+  s.version = Asciidoctor::PlantUML::VERSION
+  s.authors = ['Horacio Sanson']
+  s.email = ['hsanson@gmail.com']
+  s.description = 'Asciidoctor PlantUML extension'
+  s.summary = 'Asciidoctor support for PlantUML diagrams.'
+  s.platform = Gem::Platform::RUBY
+  s.homepage = 'https://github.com/hsanson/asciidoctor-plantuml'
+  s.license = 'MIT'
+  s.files = `git ls-files -z -- */* {LICENSE,README,Rakefile}*`.split "\x0"
 
-  if s.respond_to? :specification_version then
-    s.specification_version = 4
-  end
+  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
+  s.test_files = s.files.grep(%r{^(test|spec|features)/})
+  s.require_paths = ['lib']
 
-  if s.respond_to? :add_runtime_dependency then
-    s.add_runtime_dependency(%q<asciidoctor>.freeze, [">= 2.0.17", "< 3.0.0"])
-    s.add_development_dependency(%q<bundler>.freeze, ["~> 2.2"])
-    s.add_development_dependency(%q<nokogiri>.freeze, ["~> 1.13.4"])
-    s.add_development_dependency(%q<rake>.freeze, ["~> 13.0"])
-    s.add_development_dependency(%q<rubocop>.freeze, ["~> 1.28"])
-    s.add_development_dependency(%q<test-unit>.freeze, ["~> 3.5"])
-  else
-    s.add_dependency(%q<asciidoctor>.freeze, [">= 2.0.17", "< 3.0.0"])
-    s.add_dependency(%q<bundler>.freeze, ["~> 2.2"])
-    s.add_dependency(%q<nokogiri>.freeze, ["~> 1.13.4"])
-    s.add_dependency(%q<rake>.freeze, ["~> 13.0"])
-    s.add_dependency(%q<rubocop>.freeze, ["~> 1.28"])
-    s.add_dependency(%q<test-unit>.freeze, ["~> 3.5"])
-  end
+  s.required_ruby_version = '>= 2.6'
+  s.add_development_dependency 'bundler', '~> 2.2'
+  s.add_development_dependency 'nokogiri', '~> 1.13.6'
+  s.add_development_dependency 'rake', '~> 13.0'
+  s.add_development_dependency 'rubocop', '~> 1.28'
+  s.add_development_dependency 'test-unit', '~> 3.5'
+  s.add_runtime_dependency 'asciidoctor', '>= 2.0.17', '< 3.0.0'
+  s.metadata['rubygems_mfa_required'] = 'true'
 end
diff --git a/debian/changelog b/debian/changelog
index 8e9fcbd..a9f3320 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-asciidoctor-plantuml (0.1.1+git20221208.1.6a72d7a-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 04:40:45 -0000
+
 ruby-asciidoctor-plantuml (0.0.16-1) unstable; urgency=medium
 
   [ Balasankar C ]
diff --git a/lib/asciidoctor-plantuml.rb b/lib/asciidoctor-plantuml.rb
index 97e0a66..83bd652 100644
--- a/lib/asciidoctor-plantuml.rb
+++ b/lib/asciidoctor-plantuml.rb
@@ -6,4 +6,5 @@ require_relative 'asciidoctor_plantuml/plantuml'
 
 Asciidoctor::Extensions.register do
   block Asciidoctor::PlantUml::BlockProcessor, :plantuml
+  block_macro Asciidoctor::PlantUml::BlockMacroProcessor, :plantuml
 end
diff --git a/lib/asciidoctor_plantuml/plantuml.rb b/lib/asciidoctor_plantuml/plantuml.rb
index 9077e60..cf9f57d 100644
--- a/lib/asciidoctor_plantuml/plantuml.rb
+++ b/lib/asciidoctor_plantuml/plantuml.rb
@@ -78,23 +78,56 @@ module Asciidoctor
           txt_enabled? || png_enabled? || svg_enabled?
         end
 
-        def plantuml_content_format(code, format, attrs = {})
-          if %w[png svg txt].include?(format) &&
-             method("#{format}_enabled?").call
-            method("plantuml_#{format}_content").call(code, format, attrs)
+        def plantuml_content_format(parent, code, format, attrs = {})
+          content = code.read
+
+          # honor subs attributes
+          # e.g. replace asciidoc variables
+          subs = attrs['subs']
+          content = parent.apply_subs(content, parent.resolve_subs(subs)) if subs
+
+          # add @start... and @end... if missing
+          content = "@startuml\n#{content}\n@enduml" unless content =~ /^@start.*@end[a-z]*$/m
+
+          # insert global plantuml config after first line
+          config_path = parent.attr('plantuml-include', '', true)
+
+          unless config_path.empty?
+            begin
+              source_file = parent.document.normalize_system_path(config_path, nil, nil, recover: false)
+              content = insert_config_to_content(parent, source_file, content, attrs)
+            rescue StandardError => e
+              return plantuml_invalid_file(source_file, e.message, attrs)
+            rescue SecurityError => e
+              return plantuml_insecure_file(source_file, e.message, attrs)
+            end
+          end
+
+          if %w[png svg txt].include?(format) && method("#{format}_enabled?").call
+            method("plantuml_#{format}_content").call(content, format, attrs)
           else
             plantuml_invalid_content(format, attrs)
           end
         end
 
-        def plantuml_content(code, attrs = {})
+        def plantuml_content(parent, code, attrs = {})
           format = attrs['format'] || DEFAULT_FORMAT
 
           return plantuml_disabled_content(code, attrs) unless enabled?
 
           return plantuml_server_unavailable_content(server_url, attrs) unless valid_uri?(server_url)
 
-          plantuml_content_format(code, format, attrs)
+          plantuml_content_format(parent, code, format, attrs)
+        end
+
+        def plantuml_content_from_file(parent, target, attrs = {})
+          source_file = parent.document.normalize_system_path(target, nil, nil, recover: false)
+          content = ::File.open(source_file, mode: FILE_READ_MODE)
+          plantuml_content(parent, content, attrs)
+        rescue StandardError => e
+          plantuml_invalid_file(source_file, e.message, attrs)
+        rescue SecurityError => e
+          plantuml_insecure_file(source_file, e.message, attrs)
         end
 
         # Compression code used to generate PlantUML URLs. Taken directly from
@@ -113,8 +146,23 @@ module Asciidoctor
           join_paths(server_url, "#{format}/", result).to_s
         end
 
+        def create_plantuml_block(parent, content, attrs)
+          Asciidoctor::Block.new parent, :pass, {
+            content_model: :raw,
+            source: content,
+            subs: :default
+          }.merge(attrs)
+        end
+
         private
 
+        def insert_config_to_content(parent, config_path, content, attrs)
+          config = File.read(config_path, mode: FILE_READ_MODE)
+          subs = attrs['subs']
+          config = parent.apply_subs(config, parent.resolve_subs(subs)) if subs
+          return content.dup.insert(content.index("\n"), "\n#{config}") unless config.empty?
+        end
+
         def plantuml_txt_content(code, format, attrs = {})
           url = gen_url(code, format)
           URI(url).open do |f|
@@ -180,6 +228,16 @@ module Asciidoctor
           _plantuml_error_content(code, attrs)
         end
 
+        def plantuml_invalid_file(file, error, attrs = {})
+          error = "PlantUML Error: Could not parse \"#{file}\": #{error}"
+          _plantuml_error_content(error, attrs)
+        end
+
+        def plantuml_insecure_file(file, error, attrs = {})
+          error = "PlantUML Error: Could not read \"#{file}\": #{error}"
+          _plantuml_error_content(error, attrs)
+        end
+
         def _plantuml_error_content(error, attrs = {})
           content = '<div class="listingblock">'
           content += '<div class="content">'
@@ -263,25 +321,19 @@ module Asciidoctor
       content_model :simple
 
       def process(parent, target, attrs)
-        lines = target.lines
-
-        lines = ['@startuml'] + target.lines unless target.lines[0] =~ /@startuml/
-
-        lines += ['@enduml'] unless target.lines[-1] =~ /@enduml/
-
-        content = Processor.plantuml_content(lines.join("\n"), attrs)
-
-        create_plantuml_block(parent, content, attrs)
+        content = Processor.plantuml_content(parent, target, attrs)
+        Processor.create_plantuml_block(parent, content, attrs)
       end
+    end
 
-      private
+    # PlantUML BlockMacroProcessor
+    class BlockMacroProcessor < Asciidoctor::Extensions::BlockMacroProcessor
+      use_dsl
+      named :plantuml
 
-      def create_plantuml_block(parent, content, attrs)
-        Asciidoctor::Block.new parent, :pass,  {
-          content_model: :raw,
-          source: content,
-          subs: :default
-        }.merge(attrs)
+      def process(parent, target, attrs)
+        content = Processor.plantuml_content_from_file(parent, target, attrs)
+        Processor.create_plantuml_block(parent, content, attrs)
       end
     end
   end
diff --git a/lib/asciidoctor_plantuml/version.rb b/lib/asciidoctor_plantuml/version.rb
index ee35038..1ebf6db 100644
--- a/lib/asciidoctor_plantuml/version.rb
+++ b/lib/asciidoctor_plantuml/version.rb
@@ -2,6 +2,6 @@
 
 module Asciidoctor
   module PlantUML
-    VERSION = '0.0.16'
+    VERSION = '0.1.1'
   end
 end
diff --git a/test/fixtures/config.puml b/test/fixtures/config.puml
new file mode 100644
index 0000000..328674a
--- /dev/null
+++ b/test/fixtures/config.puml
@@ -0,0 +1,3 @@
+skinparam monochrome true
+skinparam backgroundColor transparent
+skinparam style strictuml
\ No newline at end of file
diff --git a/test/fixtures/test.puml b/test/fixtures/test.puml
new file mode 100644
index 0000000..91e5e6c
--- /dev/null
+++ b/test/fixtures/test.puml
@@ -0,0 +1,4 @@
+@startuml
+User -> (Start)
+User --> (Use the application) : Label
+@enduml
\ No newline at end of file
diff --git a/test/test_plantuml.rb b/test/test_plantuml.rb
index ea4dc9b..a91c6cf 100644
--- a/test/test_plantuml.rb
+++ b/test/test_plantuml.rb
@@ -184,10 +184,88 @@ DOC_SVG = <<~ENDOFSTRING
   ----
 ENDOFSTRING
 
+DOC_BLOCK_MACRO = <<~ENDOFSTRING
+  = Hello PlantUML!
+
+  .Title Of this
+  plantuml::test/fixtures/test.puml[]
+ENDOFSTRING
+
+DOC_BLOCK_MACRO_MISSING_FILE = <<~ENDOFSTRING
+  = Hello PlantUML!
+
+  .Title Of this
+  plantuml::test/fixtures/missing.puml[]
+ENDOFSTRING
+
+DOC_BLOCK_MACRO_INSECURE_FILE = <<~ENDOFSTRING
+  = Hello PlantUML!
+
+  .Title Of this
+  plantuml::/etc/passwd[]
+ENDOFSTRING
+
+DOC_SUBS_ATTRIBUTES = <<~ENDOFSTRING
+  = Hello PlantUML!
+  :text: Label
+
+  [plantuml, format="png", subs="attributes+"]
+  .Title Of this
+  ----
+  User -> (Start)
+  User --> (Use the application) : {text}
+  ----
+ENDOFSTRING
+
+DOC_CONFIG_INCLUDE = <<~ENDOFSTRING
+  = Hello PlantUML!
+  :plantuml-include: test/fixtures/config.puml
+
+  [plantuml, format="png"]
+  .Title Of this
+  ----
+  User -> (Start)
+  User --> (Use the application) : Label
+  ----
+ENDOFSTRING
+
+DOC_CONFIG_INCLUDE_MISSING_FILE = <<~ENDOFSTRING
+  = Hello PlantUML!
+  :plantuml-include: test/fixtures/missing.puml
+
+  [plantuml, format="png"]
+  .Title Of this
+  ----
+  User -> (Start)
+  User --> (Use the application) : Label
+  ----
+ENDOFSTRING
+
+DOC_CONFIG_INCLUDE_INSECURE_FILE = <<~ENDOFSTRING
+  = Hello PlantUML!
+  :plantuml-include: /etc/passwd
+
+  [plantuml, format="png"]
+  .Title Of this
+  ----
+  User -> (Start)
+  User --> (Use the application) : Label
+  ----
+ENDOFSTRING
+
+DOC_CONFIG_INCLUDE_MACRO_BLOCK = <<~ENDOFSTRING
+  = Hello PlantUML!
+  :plantuml-include: test/fixtures/config.puml
+
+  [plantuml, format="png"]
+  plantuml::test/fixtures/test.puml[]
+ENDOFSTRING
+
 class PlantUmlTest < Test::Unit::TestCase
   GENURL = 'http://localhost:8080/plantuml/png/U9npA2v9B2efpStX2YrEBLBGjLFG20Q9Q4Bv804WIw4a8rKXiQ0W9pCviIGpFqzJmKh19p4fDOVB8JKl1QWT05kd5wq0'
   GENURL2 = 'http://localhost:8080/plantuml/png/U9npA2v9B2efpStXYdRszmqmZ8NGHh4mleAkdGAAa15G22Pc7Clba9gN0jGE00W75Cm0'
   GENURL_ENCODING = 'http://localhost:8080/plantuml/png/~1U9npA2v9B2efpStX2YrEBLBGjLFG20Q9Q4Bv804WIw4a8rKXiQ0W9pCviIGpFqzJmKh19p4fDOVB8JKl1QWT05kd5wq0'
+  GENURL_CONFIG = 'http://localhost:8080/plantuml/png/~1U9nDZJ4Emp08HVUSWh4PUe4ELQIktQeUW3YeiMA31NZexKEg3bc-Fly1Vp97zLxBO5lcXeeLgh2aLQKIk7OwaHdJzb7fl3oaY0P6ja34Vjeo_nOArPn-dzz62jSxN5v7r_YVZo0S-4g0hPMSqBFm23Tuuanbc8YNEDy1SzOwlG00'
   SVGGENURL = 'http://localhost:8080/plantuml/svg/~1U9npA2v9B2efpStX2YrEBLBGjLFG20Q9Q4Bv804WIw4a8rKXiQ0W9pCviIGpFqzJmKh19p4fDOVB8JKl1QWT05kd5wq0'
 
   def setup
@@ -302,6 +380,94 @@ class PlantUmlTest < Test::Unit::TestCase
     assert_equal GENURL_ENCODING, element['src']
   end
 
+  def test_plantuml_block_macro_processor
+    html = ::Asciidoctor.convert(StringIO.new(DOC_BLOCK_MACRO), backend: 'html5')
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('img.plantuml')
+
+    assert_equal elements.size, 1
+
+    element = elements.first
+
+    assert_equal GENURL, element['src']
+  end
+
+  def test_should_show_file_error
+    html = ::Asciidoctor.convert(StringIO.new(DOC_BLOCK_MACRO_MISSING_FILE), backend: 'html5', safe: :secure)
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('pre.plantuml-error')
+    assert_equal elements.size, 1
+    assert_includes html, 'No such file or directory'
+  end
+
+  def test_should_show_insecure_error
+    html = ::Asciidoctor.convert(StringIO.new(DOC_BLOCK_MACRO_INSECURE_FILE), backend: 'html5', safe: :secure)
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('pre.plantuml-error')
+    assert_equal elements.size, 1
+    assert_includes html, 'is outside of jail'
+  end
+
+  def test_plantuml_subs_attributes
+    html = ::Asciidoctor.convert(StringIO.new(DOC_SUBS_ATTRIBUTES), backend: 'html5')
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('img.plantuml')
+
+    assert_equal elements.size, 1
+
+    element = elements.first
+
+    assert_equal GENURL_ENCODING, element['src']
+  end
+
+  def test_plantuml_config_include
+    html = ::Asciidoctor.convert(StringIO.new(DOC_CONFIG_INCLUDE), backend: 'html5', safe: :secure)
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('img.plantuml')
+
+    assert_equal elements.size, 1
+
+    element = elements.first
+
+    assert_equal GENURL_CONFIG, element['src']
+  end
+
+  def test_plantuml_config_include_missing_file
+    html = ::Asciidoctor.convert(StringIO.new(DOC_CONFIG_INCLUDE_MISSING_FILE), backend: 'html5')
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('pre.plantuml-error')
+    assert_equal elements.size, 1
+    assert_includes html, 'No such file or directory'
+  end
+
+  def test_plantuml_config_include_insecure_file
+    html = ::Asciidoctor.convert(StringIO.new(DOC_CONFIG_INCLUDE_INSECURE_FILE), backend: 'html5', safe: :secure)
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('pre.plantuml-error')
+    assert_equal elements.size, 1
+    assert_includes html, 'is outside of jail'
+  end
+
+  def test_plantuml_config_include_macro_block
+    html = ::Asciidoctor.convert(StringIO.new(DOC_CONFIG_INCLUDE_MACRO_BLOCK), backend: 'html5', safe: :secure)
+    page = Nokogiri::HTML(html)
+
+    elements = page.css('img.plantuml')
+
+    assert_equal elements.size, 1
+
+    element = elements.first
+
+    assert_equal GENURL_CONFIG, element['src']
+  end
+
   def test_plantuml_id_attribute
     html = ::Asciidoctor.convert(StringIO.new(DOC_ID), backend: 'html5')
     page = Nokogiri::HTML(html)

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/asciidoctor-plantuml-0.1.1.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/asciidoctor-plantuml-0.0.16.gemspec

No differences were encountered in the control files

More details

Full run details