asciidoctor-diagram 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +8 -0
- data/README.adoc +2 -0
- data/lib/asciidoctor-diagram.rb +1 -0
- data/lib/asciidoctor-diagram/a2s/extension.rb +4 -4
- data/lib/asciidoctor-diagram/plantuml/extension.rb +2 -2
- data/lib/asciidoctor-diagram/tikz.rb +7 -0
- data/lib/asciidoctor-diagram/tikz/extension.rb +68 -0
- data/lib/asciidoctor-diagram/util/java_jruby.rb +1 -1
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/plantuml.jar +0 -0
- data/spec/plantuml_spec.rb +48 -0
- data/spec/test_helper.rb +1 -0
- data/spec/tikz_spec.rb +127 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b210b428ba58c0332817b65d14cbcf5140fa5d23
|
4
|
+
data.tar.gz: aa70930c788129a4b352b96b69d195ab40bacc59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db4a23dc9a0f9edf9683b58d5967153eefa2b938cb6da46a5a3bdfa9d0cde59ee1875a94f8ece94588b1f11023c6064ec1bdcac0f5fd33a48bcd6e479729197b
|
7
|
+
data.tar.gz: f353f04830771ed1141a3abef0b685af085f1157f9990ebdf93904dcc944317631c0c532177a7e5a1e070dec3eb97dc7649d395964d5dc8f65d361a9250d0a09
|
data/CHANGELOG.adoc
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= Asciidoctor-diagram Changelog
|
2
2
|
|
3
|
+
== 1.5.10
|
4
|
+
|
5
|
+
Bug Fixes::
|
6
|
+
|
7
|
+
* Issue #186: Avoid preprocessing of PlantUML stdlib !includes (@habamax)
|
8
|
+
* Issue #193: Update PlantUML to 2018.10
|
9
|
+
* Issue #194: Silence unitialized instance variable warning when using JRuby
|
10
|
+
|
3
11
|
== 1.5.9
|
4
12
|
|
5
13
|
Enhancements::
|
data/README.adoc
CHANGED
@@ -52,9 +52,11 @@ The generated file is then inserted into your converted document.
|
|
52
52
|
|
53
53
|
Asciidoctor Diagram was inspired by the {uri-py-plantuml}[AsciiDoc PlantUML filter].
|
54
54
|
|
55
|
+
ifndef::env-site[]
|
55
56
|
Translations of the document are available in the following languages:
|
56
57
|
|
57
58
|
* link:README_zh-CN.adoc[汉语]
|
59
|
+
endif::[]
|
58
60
|
|
59
61
|
ifdef::status[]
|
60
62
|
[discrete]
|
data/lib/asciidoctor-diagram.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative 'asciidoctor-diagram/salt'
|
|
11
11
|
require_relative 'asciidoctor-diagram/shaape'
|
12
12
|
require_relative 'asciidoctor-diagram/svgbob'
|
13
13
|
require_relative 'asciidoctor-diagram/syntrax'
|
14
|
+
require_relative 'asciidoctor-diagram/tikz'
|
14
15
|
require_relative 'asciidoctor-diagram/umlet'
|
15
16
|
require_relative 'asciidoctor-diagram/vega'
|
16
17
|
require_relative 'asciidoctor-diagram/wavedrom'
|
@@ -28,12 +28,12 @@ module Asciidoctor
|
|
28
28
|
font = source.attr('fontfamily', nil, inherit_prefix)
|
29
29
|
|
30
30
|
generate_stdin(which(parent, 'a2s'), format.to_s, source.to_s) do |tool_path, output_path|
|
31
|
-
args = [tool_path,
|
31
|
+
args = [tool_path, '-o', Platform.native_path(output_path)]
|
32
32
|
|
33
33
|
if sx && sy
|
34
|
-
args <<
|
34
|
+
args << '-s' << "#{sx},#{sy}"
|
35
35
|
elsif scale
|
36
|
-
args <<
|
36
|
+
args << '-s' << "#{scale},#{scale}"
|
37
37
|
end
|
38
38
|
|
39
39
|
if noblur
|
@@ -41,7 +41,7 @@ module Asciidoctor
|
|
41
41
|
end
|
42
42
|
|
43
43
|
if font
|
44
|
-
args <<
|
44
|
+
args << '-f' << font
|
45
45
|
end
|
46
46
|
|
47
47
|
args
|
@@ -58,8 +58,8 @@ module Asciidoctor
|
|
58
58
|
resolve_path(match, parent, parent.attr('imagesdir'))
|
59
59
|
end
|
60
60
|
|
61
|
-
code.gsub!(/(?<=!include )[^!\n\r]+/) do |match|
|
62
|
-
resolve_path(match, parent, base_dir)
|
61
|
+
code.gsub!(/(?<=!include )\s*[^<][^!\n\r]+/) do |match|
|
62
|
+
resolve_path(match.lstrip, parent, base_dir)
|
63
63
|
end
|
64
64
|
|
65
65
|
code
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../extensions'
|
2
|
+
require_relative '../util/cli_generator'
|
3
|
+
require_relative '../util/platform'
|
4
|
+
require_relative '../util/which'
|
5
|
+
|
6
|
+
module Asciidoctor
|
7
|
+
module Diagram
|
8
|
+
# @private
|
9
|
+
module TikZ
|
10
|
+
include CliGenerator
|
11
|
+
include Which
|
12
|
+
|
13
|
+
def self.included(mod)
|
14
|
+
[:pdf, :svg].each do |f|
|
15
|
+
mod.register_format(f, :image) do |parent, source|
|
16
|
+
tikz(parent, source, f)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def tikz(parent, source, format)
|
22
|
+
latexpath = which(parent, 'pdflatex')
|
23
|
+
|
24
|
+
if format == :svg
|
25
|
+
svgpath = which(parent, 'pdf2svg')
|
26
|
+
else
|
27
|
+
svgpath = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
latex = <<'END'
|
31
|
+
\documentclass[border=2bp]{standalone}
|
32
|
+
\usepackage{tikz}
|
33
|
+
\begin{document}
|
34
|
+
\begingroup
|
35
|
+
\tikzset{every picture/.style={scale=1}}
|
36
|
+
END
|
37
|
+
latex << source.to_s
|
38
|
+
latex << <<'END'
|
39
|
+
\endgroup
|
40
|
+
\end{document}
|
41
|
+
END
|
42
|
+
|
43
|
+
pdf = generate_file(latexpath, 'tex', 'pdf', latex) do |tool_path, input_path, output_path|
|
44
|
+
{
|
45
|
+
:args => [tool_path, '-shell-escape', '-file-line-error', '-interaction=nonstopmode', '-output-directory', Platform.native_path(File.dirname(output_path)), Platform.native_path(input_path)],
|
46
|
+
:out_file => "#{File.dirname(input_path)}/#{File.basename(input_path, '.*')}.pdf"
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
if svgpath
|
51
|
+
generate_file(svgpath, 'pdf', 'svg', pdf) do |tool_path, input_path, output_path|
|
52
|
+
[tool_path, Platform.native_path(File.dirname(input_path)), Platform.native_path(File.dirname(output_path))]
|
53
|
+
end
|
54
|
+
else
|
55
|
+
pdf
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class TikZBlockProcessor < Extensions::DiagramBlockProcessor
|
61
|
+
include TikZ
|
62
|
+
end
|
63
|
+
|
64
|
+
class TikZBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
|
65
|
+
include TikZ
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/plantuml.jar
CHANGED
Binary file
|
data/spec/plantuml_spec.rb
CHANGED
@@ -808,6 +808,54 @@ List <|.. ArrayList
|
|
808
808
|
expect(content).to_not include('!include')
|
809
809
|
end
|
810
810
|
|
811
|
+
it 'should not resolve stdlib !include directives' do
|
812
|
+
doc = <<-eos
|
813
|
+
= Hello, PlantUML!
|
814
|
+
Doc Writer <doc@example.com>
|
815
|
+
|
816
|
+
== First Section
|
817
|
+
|
818
|
+
[plantuml, format="svg"]
|
819
|
+
----
|
820
|
+
@startuml
|
821
|
+
!include <tupadr3/common>
|
822
|
+
!include <tupadr3/font-awesome/server>
|
823
|
+
!include <tupadr3/font-awesome/database>
|
824
|
+
|
825
|
+
title Styling example
|
826
|
+
|
827
|
+
FA_SERVER(web1,web1) #Green
|
828
|
+
FA_SERVER(web2,web2) #Yellow
|
829
|
+
FA_SERVER(web3,web3) #Blue
|
830
|
+
FA_SERVER(web4,web4) #YellowGreen
|
831
|
+
|
832
|
+
FA_DATABASE(db1,LIVE,database,white) #RoyalBlue
|
833
|
+
FA_DATABASE(db2,SPARE,database) #Red
|
834
|
+
|
835
|
+
db1 <--> db2
|
836
|
+
|
837
|
+
web1 <--> db1
|
838
|
+
web2 <--> db1
|
839
|
+
web3 <--> db1
|
840
|
+
web4 <--> db1
|
841
|
+
@enduml
|
842
|
+
----
|
843
|
+
eos
|
844
|
+
|
845
|
+
d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
|
846
|
+
|
847
|
+
expect(d).to_not be_nil
|
848
|
+
|
849
|
+
b = d.find { |bl| bl.context == :image }
|
850
|
+
expect(b).to_not be_nil
|
851
|
+
|
852
|
+
target = b.attributes['target']
|
853
|
+
expect(File.exist?(target)).to be true
|
854
|
+
|
855
|
+
content = File.read(target, :encoding => Encoding::UTF_8)
|
856
|
+
expect(content).to_not include('!include')
|
857
|
+
end
|
858
|
+
|
811
859
|
it 'should support substitutions' do
|
812
860
|
doc = <<-eos
|
813
861
|
= Hello, PlantUML!
|
data/spec/test_helper.rb
CHANGED
@@ -18,6 +18,7 @@ require_relative '../lib/asciidoctor-diagram/plantuml/extension'
|
|
18
18
|
require_relative '../lib/asciidoctor-diagram/shaape/extension'
|
19
19
|
require_relative '../lib/asciidoctor-diagram/svgbob/extension'
|
20
20
|
require_relative '../lib/asciidoctor-diagram/syntrax/extension'
|
21
|
+
require_relative '../lib/asciidoctor-diagram/tikz/extension'
|
21
22
|
require_relative '../lib/asciidoctor-diagram/umlet/extension'
|
22
23
|
require_relative '../lib/asciidoctor-diagram/vega/extension'
|
23
24
|
require_relative '../lib/asciidoctor-diagram/wavedrom/extension'
|
data/spec/tikz_spec.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-'eos'
|
4
|
+
\begin{tikzpicture}[font=\LARGE]
|
5
|
+
|
6
|
+
% Figure parameters (tta and k needs to have the same sign)
|
7
|
+
% They can be modified at will
|
8
|
+
\def \tta{ -10.00000000000000 } % Defines the first angle of perspective
|
9
|
+
\def \k{ -3.00000000000000 } % Factor for second angle of perspective
|
10
|
+
\def \l{ 6.00000000000000 } % Defines the width of the parallelepiped
|
11
|
+
\def \d{ 5.00000000000000 } % Defines the depth of the parallelepiped
|
12
|
+
\def \h{ 7.00000000000000 } % Defines the heigth of the parallelepiped
|
13
|
+
|
14
|
+
% The vertices A,B,C,D define the reference plan (vertical)
|
15
|
+
\coordinate (A) at (0,0);
|
16
|
+
\coordinate (B) at ({-\h*sin(\tta)},{\h*cos(\tta)});
|
17
|
+
\coordinate (C) at ({-\h*sin(\tta)-\d*sin(\k*\tta)},
|
18
|
+
{\h*cos(\tta)+\d*cos(\k*\tta)});
|
19
|
+
\coordinate (D) at ({-\d*sin(\k*\tta)},{\d*cos(\k*\tta)});
|
20
|
+
|
21
|
+
% The vertices Ap,Bp,Cp,Dp define a plane translated from the
|
22
|
+
% reference plane by the width of the parallelepiped
|
23
|
+
\coordinate (Ap) at (\l,0);
|
24
|
+
\coordinate (Bp) at ({\l-\h*sin(\tta)},{\h*cos(\tta)});
|
25
|
+
\coordinate (Cp) at ({\l-\h*sin(\tta)-\d*sin(\k*\tta)},
|
26
|
+
{\h*cos(\tta)+\d*cos(\k*\tta)});
|
27
|
+
\coordinate (Dp) at ({\l-\d*sin(\k*\tta)},{\d*cos(\k*\tta)});
|
28
|
+
|
29
|
+
% Marking the vertices of the tetrahedron (red)
|
30
|
+
% and of the parallelepiped (black)
|
31
|
+
\fill[black] (A) circle [radius=2pt];
|
32
|
+
\fill[red] (B) circle [radius=2pt];
|
33
|
+
\fill[black] (C) circle [radius=2pt];
|
34
|
+
\fill[red] (D) circle [radius=2pt];
|
35
|
+
\fill[red] (Ap) circle [radius=2pt];
|
36
|
+
\fill[black] (Bp) circle [radius=2pt];
|
37
|
+
\fill[red] (Cp) circle [radius=2pt];
|
38
|
+
\fill[black] (Dp) circle [radius=2pt];
|
39
|
+
|
40
|
+
% painting first the three visible faces of the tetrahedron
|
41
|
+
\filldraw[draw=red,bottom color=red!50!black, top color=cyan!50]
|
42
|
+
(B) -- (Cp) -- (D);
|
43
|
+
\filldraw[draw=red,bottom color=red!50!black, top color=cyan!50]
|
44
|
+
(B) -- (D) -- (Ap);
|
45
|
+
\filldraw[draw=red,bottom color=red!50!black, top color=cyan!50]
|
46
|
+
(B) -- (Cp) -- (Ap);
|
47
|
+
|
48
|
+
% Draw the edges of the tetrahedron
|
49
|
+
\draw[red,-,very thick] (Ap) -- (D)
|
50
|
+
(Ap) -- (B)
|
51
|
+
(Ap) -- (Cp)
|
52
|
+
(B) -- (D)
|
53
|
+
(Cp) -- (D)
|
54
|
+
(B) -- (Cp);
|
55
|
+
|
56
|
+
% Draw the visible edges of the parallelepiped
|
57
|
+
\draw [-,thin] (B) -- (A)
|
58
|
+
(Ap) -- (Bp)
|
59
|
+
(B) -- (C)
|
60
|
+
(D) -- (C)
|
61
|
+
(A) -- (D)
|
62
|
+
(Ap) -- (A)
|
63
|
+
(Cp) -- (C)
|
64
|
+
(Bp) -- (B)
|
65
|
+
(Bp) -- (Cp);
|
66
|
+
|
67
|
+
% Draw the hidden edges of the parallelepiped
|
68
|
+
\draw [gray,-,thin] (Dp) -- (Cp);
|
69
|
+
(Dp) -- (D);
|
70
|
+
(Ap) -- (Dp);
|
71
|
+
|
72
|
+
% Name the vertices (the names are not consistent
|
73
|
+
% with the node name, but it makes the programming easier)
|
74
|
+
\draw (Ap) node [right] {$A$}
|
75
|
+
(Bp) node [right, gray] {$F$}
|
76
|
+
(Cp) node [right] {$D$}
|
77
|
+
(C) node [left,gray] {$E$}
|
78
|
+
(D) node [left] {$B$}
|
79
|
+
(A) node [left,gray] {$G$}
|
80
|
+
(B) node [above left=+5pt] {$C$}
|
81
|
+
(Dp) node [right,gray] {$H$};
|
82
|
+
|
83
|
+
% Drawing again vertex $C$, node (B) because it disappeared behind the edges.
|
84
|
+
% Drawing again vertex $H$, node (Dp) because it disappeared behind the edges.
|
85
|
+
\fill[red] (B) circle [radius=2pt];
|
86
|
+
\fill[gray] (Dp) circle [radius=2pt];
|
87
|
+
|
88
|
+
% From the reference and this example one can easily draw
|
89
|
+
% the twin tetrahedron jointly to this one.
|
90
|
+
% Drawing the edges of the twin tetrahedron
|
91
|
+
% switching the p_s: A <-> Ap, etc...
|
92
|
+
\draw[red,-,dashed, thin] (A) -- (Dp)
|
93
|
+
(A) -- (Bp)
|
94
|
+
(A) -- (C)
|
95
|
+
(Bp) -- (Dp)
|
96
|
+
(C) -- (Dp)
|
97
|
+
(Bp) -- (C);
|
98
|
+
\end{tikzpicture}
|
99
|
+
eos
|
100
|
+
|
101
|
+
describe Asciidoctor::Diagram::TikZBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
|
102
|
+
it "should generate PDF images when format is set to 'pdf'" do
|
103
|
+
File.write('tikz.txt', code)
|
104
|
+
|
105
|
+
doc = <<-eos
|
106
|
+
= Hello, Tikz!
|
107
|
+
Doc Writer <doc@example.com>
|
108
|
+
|
109
|
+
== First Section
|
110
|
+
|
111
|
+
tikz::tikz.txt[format="pdf"]
|
112
|
+
eos
|
113
|
+
|
114
|
+
d = load_asciidoc doc
|
115
|
+
expect(d).to_not be_nil
|
116
|
+
|
117
|
+
b = d.find { |bl| bl.context == :image }
|
118
|
+
expect(b).to_not be_nil
|
119
|
+
|
120
|
+
expect(b.content_model).to eq :empty
|
121
|
+
|
122
|
+
target = b.attributes['target']
|
123
|
+
expect(target).to_not be_nil
|
124
|
+
expect(target).to match(/\.pdf/)
|
125
|
+
expect(File.exist?(target)).to be true
|
126
|
+
end
|
127
|
+
end
|
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: 1.5.
|
4
|
+
version: 1.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pepijn Van Eeckhoudt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,6 +111,8 @@ files:
|
|
111
111
|
- lib/asciidoctor-diagram/svgbob/extension.rb
|
112
112
|
- lib/asciidoctor-diagram/syntrax.rb
|
113
113
|
- lib/asciidoctor-diagram/syntrax/extension.rb
|
114
|
+
- lib/asciidoctor-diagram/tikz.rb
|
115
|
+
- lib/asciidoctor-diagram/tikz/extension.rb
|
114
116
|
- lib/asciidoctor-diagram/umlet.rb
|
115
117
|
- lib/asciidoctor-diagram/umlet/extension.rb
|
116
118
|
- lib/asciidoctor-diagram/util/binaryio.rb
|
@@ -151,6 +153,7 @@ files:
|
|
151
153
|
- spec/svgbob_spec.rb
|
152
154
|
- spec/syntrax_spec.rb
|
153
155
|
- spec/test_helper.rb
|
156
|
+
- spec/tikz_spec.rb
|
154
157
|
- spec/umlet_spec.rb
|
155
158
|
- spec/vega_spec.rb
|
156
159
|
- spec/wavedrom_spec.rb
|
@@ -194,6 +197,7 @@ test_files:
|
|
194
197
|
- spec/svgbob_spec.rb
|
195
198
|
- spec/syntrax_spec.rb
|
196
199
|
- spec/test_helper.rb
|
200
|
+
- spec/tikz_spec.rb
|
197
201
|
- spec/umlet_spec.rb
|
198
202
|
- spec/vega_spec.rb
|
199
203
|
- spec/wavedrom_spec.rb
|