asciidoctor-diagram 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +6 -0
- data/docs/modules/ROOT/pages/index.adoc +2 -2
- data/docs/modules/ROOT/partials/advanced.adoc +6 -5
- data/lib/asciidoctor-diagram/meme/converter.rb +26 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +47 -23
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.22.jar +0 -0
- data/lib/asciidoctor-diagram/util/svg.rb +5 -3
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/spec/plantuml_spec.rb +28 -0
- metadata +7 -7
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7b68569773e4811496a15d962840a88567ec7e7890d91d38a38c742477c24b
|
4
|
+
data.tar.gz: 7f7f72e9433adbbc0ee21537db7d96b5469b22979b9f82930d97d4a70614e6a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b65b14640274daf2a670f44330d261a2712df4d3ee696cd4a0fe8df395258716d2213d9d8de143117e67b1d66750b8bb5c8c892888e6477c1171a81ac53904
|
7
|
+
data.tar.gz: 96cc74fbfa0649906618089719b3d204f6d6127b0b81c648b6ae7f86279df54a0cdd23533a74bc898ea84ecb2653a626d58a0b82078f39710d47108c3f2a0d0c
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,12 @@
|
|
4
4
|
|
5
5
|
Enhancements::
|
6
6
|
|
7
|
+
* Issue #399: Add support for PlantUML theme attribute
|
8
|
+
|
9
|
+
== 2.2.3
|
10
|
+
|
11
|
+
Enhancements::
|
12
|
+
|
7
13
|
* Issue #373: Add support for rendering Ditaa diagrams via PlantUML using ditaamini
|
8
14
|
* Issue #383: Allow bullet characters for Ditaa to be overridden
|
9
15
|
|
@@ -5,7 +5,7 @@ include::partial$uris.adoc[]
|
|
5
5
|
|
6
6
|
Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
|
7
7
|
|
8
|
-
The extensions
|
8
|
+
The extensions support the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-bytefield}[Bytefield-SVG], {uri-ditaa}[Ditaa], {uri-dpic}[dpic], {uri-erd}[Erd], {uri-gnuplot}[Gnuplot], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-pikchr}[Pikchr], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-smcat}[State Machine Cat], {uri-svgbob}[SvgBob], {uri-symbolator}[Symbolator], {uri-syntrax}[Syntrax] / {uri-jsyntrax}[JSyntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
|
9
9
|
|
10
10
|
Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
|
11
11
|
The generated file is then inserted into your converted document.
|
@@ -18,4 +18,4 @@ include::partial$create_diagram.adoc[]
|
|
18
18
|
|
19
19
|
include::partial$generate.adoc[]
|
20
20
|
|
21
|
-
include::partial$advanced.adoc[]
|
21
|
+
include::partial$advanced.adoc[]
|
@@ -20,7 +20,7 @@ require 'asciidoctor-diagram/<extension_name>'
|
|
20
20
|
|
21
21
|
Requiring one or more of these files will automatically register the extensions for all processed documents.
|
22
22
|
|
23
|
-
If you need more fine
|
23
|
+
If you need more fine-grained control over when the extensions are enabled, `asciidoctor-diagram/<extension_name>/extension` can be used instead.
|
24
24
|
This loads the extensions but does not register it in the Asciidoctor extension registry.
|
25
25
|
You can then manually register the extensions at the appropriate times using the `Asciidoctor::Extensions` API.
|
26
26
|
|
@@ -54,13 +54,13 @@ When Asciidoctor Diagram writes images to disk it will go over the following opt
|
|
54
54
|
The image generation also outputs metadata files that by default are located in `.asciidoctor/diagram`.
|
55
55
|
To place them in different location, Asciidoctor Diagram checks for (in this order).
|
56
56
|
|
57
|
-
. `\{cachedir\}` attribute is specified in the block header (
|
57
|
+
. `\{cachedir\}` attribute is specified in the block header (i.e. `[plantuml, png, cachedir=my-cache]`)
|
58
58
|
. `\{diagram-cachedir\}` if the `diagram-cachedir` attribute has been specified
|
59
59
|
. `\{outdir\}/\{imagesdir\}`
|
60
60
|
|
61
61
|
=== Specifying Diagram Generator Paths
|
62
62
|
|
63
|
-
Asciidoctor Diagram depends on external tools to
|
63
|
+
Asciidoctor Diagram depends on external tools to generate images.
|
64
64
|
In most cases it will locate these tools automatically for you by looking for specific executables in each directory in the `PATH` environment variable.
|
65
65
|
In case you've installed a tool in a way where the executable is not in the `PATH`, you can override its location manually using document attributes.
|
66
66
|
The following table lists the tools that are required for each diagram type, the location where they can be downloaded and the document attribute you can use to override their locations.
|
@@ -110,7 +110,7 @@ If for instance you installed `actdiag` in `/home/me/actdiag/bin` and this path
|
|
110
110
|
=== The Meme Extension
|
111
111
|
|
112
112
|
The meme extension provides a basic '`Advice Animal`' style image generator.
|
113
|
-
|
113
|
+
Its usage is easiest to explain with an example.
|
114
114
|
|
115
115
|
----
|
116
116
|
meme::yunoguy.jpg[Doc writers,Y U NO // AsciiDoc]
|
@@ -144,7 +144,7 @@ Barcode macros can be specified using blocks, inline macros or block macros usin
|
|
144
144
|
<2> Barcode attributes (see the <<barcode_attributes>> attributes section)
|
145
145
|
<3> The content to encode in the barcode
|
146
146
|
|
147
|
-
By default the `content` field of the barcode macros will be interpreted as the barcode content.
|
147
|
+
By default, the `content` field of the barcode macros will be interpreted as the barcode content.
|
148
148
|
This works fine for simple barcodes, but for complex data (e.g., a vCard encoded as a QR code) this is not practical.
|
149
149
|
If the `external` attribute is set on a barcode macro, the target is interpreted as a file path.
|
150
150
|
The barcode content will then be obtained by reading the contents of the referenced file.
|
@@ -320,6 +320,7 @@ No specific attributes.
|
|
320
320
|
|===
|
321
321
|
|Name |Default value |Description
|
322
322
|
|config |unspecified |Path to a config file to pass to PlantUML.
|
323
|
+
|theme |unspecified |PlantUML theme to use.
|
323
324
|
|size-limit |4096 |The maximum dimensions (width and height) of generated diagrams.
|
324
325
|
|includedir |unspecified |sets a common directory for puml includes (plantuml.include.path)
|
325
326
|
|preprocess |true |Preprocess PlantUML code before rendering the diagram.
|
@@ -20,6 +20,26 @@ module Asciidoctor
|
|
20
20
|
raise "background attribute is required" unless bg_img
|
21
21
|
|
22
22
|
options = source.attr('options', '').split(',')
|
23
|
+
margin = source.attr('margin', '')
|
24
|
+
margin_parts = margin.split(' ')
|
25
|
+
case margin_parts.length
|
26
|
+
when 0
|
27
|
+
ml = mr = mt = mb = nil
|
28
|
+
when 1
|
29
|
+
ml = mr = mt = mb = margin_parts[0]
|
30
|
+
when 2
|
31
|
+
mt = mb = margin_parts[0]
|
32
|
+
ml = mr = margin_parts[1]
|
33
|
+
when 3
|
34
|
+
mt = margin_parts[0]
|
35
|
+
ml = mr = margin_parts[1]
|
36
|
+
mb = margin_parts[2]
|
37
|
+
else
|
38
|
+
mt = margin_parts[0]
|
39
|
+
mr = margin_parts[1]
|
40
|
+
mb = margin_parts[2]
|
41
|
+
ml = margin_parts[3]
|
42
|
+
end
|
23
43
|
|
24
44
|
{
|
25
45
|
:bg_img => bg_img,
|
@@ -29,6 +49,12 @@ module Asciidoctor
|
|
29
49
|
:stroke_color => source.attr(['strokecolor', 'stroke-color']),
|
30
50
|
:stroke_width => source.attr(['strokewidth', 'stroke-width']),
|
31
51
|
:font => source.attr('font', 'Impact'),
|
52
|
+
:font_size => source.attr('font_size', nil),
|
53
|
+
:alignment => source.attr('alignment', nil),
|
54
|
+
:margin_left => ml,
|
55
|
+
:margin_right => mr,
|
56
|
+
:margin_top => mt,
|
57
|
+
:margin_bottom => mb,
|
32
58
|
:noupcase => options.include?('noupcase'),
|
33
59
|
}
|
34
60
|
end
|
@@ -25,7 +25,7 @@ module Asciidoctor
|
|
25
25
|
Java.classpath.concat PLANTUML_JARS
|
26
26
|
|
27
27
|
def wrap_source(source)
|
28
|
-
PlantUMLPreprocessedSource.new(source, self
|
28
|
+
PlantUMLPreprocessedSource.new(source, self)
|
29
29
|
end
|
30
30
|
|
31
31
|
def supported_formats
|
@@ -33,9 +33,42 @@ module Asciidoctor
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def collect_options(source)
|
36
|
-
{
|
36
|
+
options = {
|
37
37
|
:size_limit => source.attr('size-limit', '4096')
|
38
38
|
}
|
39
|
+
|
40
|
+
theme = source.attr('theme', nil)
|
41
|
+
options[:theme] = theme if theme
|
42
|
+
|
43
|
+
options
|
44
|
+
end
|
45
|
+
|
46
|
+
def should_preprocess(source)
|
47
|
+
source.attr('preprocess', 'true') == 'true'
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_common_headers(headers, source)
|
51
|
+
base_dir = source.base_dir
|
52
|
+
|
53
|
+
config_file = source.attr('plantumlconfig', nil, true) || source.attr('config')
|
54
|
+
if config_file
|
55
|
+
headers['X-PlantUML-Config'] = File.expand_path(config_file, base_dir)
|
56
|
+
end
|
57
|
+
|
58
|
+
headers['X-PlantUML-Basedir'] = Platform.native_path(File.expand_path(base_dir))
|
59
|
+
|
60
|
+
include_dir = source.attr('includedir')
|
61
|
+
if include_dir
|
62
|
+
headers['X-PlantUML-IncludeDir'] = Platform.native_path(File.expand_path(include_dir, base_dir))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_theme_header(headers, theme)
|
67
|
+
headers['X-PlantUML-Theme'] = theme if theme
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_size_limit_header(headers, limit)
|
71
|
+
headers['X-PlantUML-SizeLimit'] = limit if limit
|
39
72
|
end
|
40
73
|
|
41
74
|
def convert(source, format, options)
|
@@ -60,11 +93,13 @@ module Asciidoctor
|
|
60
93
|
'Accept' => mime_type
|
61
94
|
}
|
62
95
|
|
63
|
-
|
64
|
-
|
65
|
-
headers['X-PlantUML-SizeLimit'] = size_limit
|
96
|
+
unless should_preprocess(source)
|
97
|
+
add_common_headers(headers, source)
|
66
98
|
end
|
67
99
|
|
100
|
+
add_theme_header(headers, options[:theme])
|
101
|
+
add_size_limit_header(headers, options[:size_limit])
|
102
|
+
|
68
103
|
dot = source.find_command('dot', :alt_attrs => ['graphvizdot'], :raise_on_error => false)
|
69
104
|
if dot
|
70
105
|
headers['X-Graphviz'] = ::Asciidoctor::Diagram::Platform.host_os_path(dot)
|
@@ -97,9 +132,9 @@ module Asciidoctor
|
|
97
132
|
end
|
98
133
|
|
99
134
|
class PlantUMLPreprocessedSource < SimpleDelegator
|
100
|
-
def initialize(source,
|
135
|
+
def initialize(source, converter)
|
101
136
|
super(source)
|
102
|
-
@
|
137
|
+
@converter = converter
|
103
138
|
end
|
104
139
|
|
105
140
|
def code
|
@@ -111,24 +146,13 @@ module Asciidoctor
|
|
111
146
|
|
112
147
|
code = __getobj__.code
|
113
148
|
|
114
|
-
|
115
|
-
|
116
|
-
should_preprocess = attr('preprocess', 'true') == 'true'
|
149
|
+
tag = @converter.class.tag
|
150
|
+
code = "@start#{tag}\n#{code}\n@end#{tag}" unless code.index("@start") && code.index("@end")
|
117
151
|
|
118
|
-
if should_preprocess
|
152
|
+
if @converter.should_preprocess(self)
|
119
153
|
headers = {}
|
120
|
-
|
121
|
-
|
122
|
-
if config_file
|
123
|
-
headers['X-PlantUML-Config'] = File.expand_path(config_file, base_dir)
|
124
|
-
end
|
125
|
-
|
126
|
-
headers['X-PlantUML-Basedir'] = Platform.native_path(File.expand_path(base_dir))
|
127
|
-
|
128
|
-
include_dir = attr('includedir')
|
129
|
-
if include_dir
|
130
|
-
headers['X-PlantUML-IncludeDir'] = Platform.native_path(File.expand_path(include_dir, base_dir))
|
131
|
-
end
|
154
|
+
@converter.add_common_headers(headers, self)
|
155
|
+
@converter.add_theme_header(headers, @converter.collect_options(self)[:theme])
|
132
156
|
|
133
157
|
response = Java.send_request(
|
134
158
|
:url => '/plantumlpreprocessor',
|
Binary file
|
@@ -28,8 +28,10 @@ module Asciidoctor
|
|
28
28
|
|
29
29
|
viewbox = root.attributes['viewBox']
|
30
30
|
if (v = VIEWBOX_REGEX.match(viewbox)) && width.nil? && height.nil?
|
31
|
-
|
32
|
-
|
31
|
+
min_x = to_numeric(v[:min_x])
|
32
|
+
min_y = to_numeric(v[:min_y])
|
33
|
+
width ||= to_numeric(v[:width]) - min_x
|
34
|
+
height ||= to_numeric(v[:height]) - min_y
|
33
35
|
end
|
34
36
|
|
35
37
|
if viewbox.nil? && width && height
|
@@ -76,7 +78,7 @@ module Asciidoctor
|
|
76
78
|
end
|
77
79
|
|
78
80
|
WIDTH_HEIGHT_REGEX = /^\s*(?<value>\d+(?:\.\d+)?)\s*(?<unit>[a-zA-Z]+)?\s*$/
|
79
|
-
VIEWBOX_REGEX = /^\s
|
81
|
+
VIEWBOX_REGEX = /^\s*(?<min_x>-?\d+(?:\.\d+)?)\s*(?<min_y>-?\d+(?:\.\d+)?)\s*(?<width>\d+(?:\.\d+)?)\s*(?<height>\d+(?:\.\d+)?)\s*$/
|
80
82
|
|
81
83
|
def self.to_px_factor(unit)
|
82
84
|
case unit
|
data/spec/plantuml_spec.rb
CHANGED
@@ -253,6 +253,34 @@ skinparam ArrowColor #DEADBE
|
|
253
253
|
expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
|
254
254
|
end
|
255
255
|
|
256
|
+
it 'should use plantuml theme when specified as a document attribute' do
|
257
|
+
doc = <<-eos
|
258
|
+
= Hello, PlantUML!
|
259
|
+
Doc Writer <doc@example.com>
|
260
|
+
:plantuml-format: svg
|
261
|
+
:plantuml-theme: spacelab
|
262
|
+
|
263
|
+
== First Section
|
264
|
+
|
265
|
+
[plantuml]
|
266
|
+
----
|
267
|
+
actor Foo1
|
268
|
+
boundary Foo2
|
269
|
+
Foo1 -> Foo2 : To boundary
|
270
|
+
----
|
271
|
+
eos
|
272
|
+
|
273
|
+
d = load_asciidoc doc
|
274
|
+
b = d.find { |bl| bl.context == :image }
|
275
|
+
|
276
|
+
target = b.attributes['target']
|
277
|
+
expect(target).to_not be_nil
|
278
|
+
expect(File.exist?(target)).to be true
|
279
|
+
|
280
|
+
svg = File.read(target, :encoding => Encoding::UTF_8)
|
281
|
+
expect(svg).to match(/<[^<]+ fill=["']url\(#gvl9ibi66ipfc0\)["']/)
|
282
|
+
end
|
283
|
+
|
256
284
|
it 'should use plantuml include dir when specified as a document attribute' do
|
257
285
|
doc = <<-eos
|
258
286
|
= Hello, PlantUML!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-diagram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pepijn Van Eeckhoudt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -204,7 +204,7 @@ files:
|
|
204
204
|
- lib/asciidoctor-diagram/plantuml.rb
|
205
205
|
- lib/asciidoctor-diagram/plantuml/converter.rb
|
206
206
|
- lib/asciidoctor-diagram/plantuml/extension.rb
|
207
|
-
- lib/asciidoctor-diagram/plantuml/plantuml-1.3.
|
207
|
+
- lib/asciidoctor-diagram/plantuml/plantuml-1.3.22.jar
|
208
208
|
- lib/asciidoctor-diagram/salt.rb
|
209
209
|
- lib/asciidoctor-diagram/shaape.rb
|
210
210
|
- lib/asciidoctor-diagram/shaape/converter.rb
|
@@ -282,7 +282,7 @@ homepage: https://github.com/asciidoctor/asciidoctor-diagram
|
|
282
282
|
licenses:
|
283
283
|
- MIT
|
284
284
|
metadata: {}
|
285
|
-
post_install_message:
|
285
|
+
post_install_message:
|
286
286
|
rdoc_options: []
|
287
287
|
require_paths:
|
288
288
|
- lib
|
@@ -297,8 +297,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
297
|
- !ruby/object:Gem::Version
|
298
298
|
version: '0'
|
299
299
|
requirements: []
|
300
|
-
rubygems_version: 3.
|
301
|
-
signing_key:
|
300
|
+
rubygems_version: 3.0.3.1
|
301
|
+
signing_key:
|
302
302
|
specification_version: 4
|
303
303
|
summary: A family of Asciidoctor extensions that generate images from a broad range
|
304
304
|
of embedded plain text diagram descriptions, including PlantUML, ditaa, Kroki, and
|
Binary file
|