asciidoctor-diagram 1.5.5 → 1.5.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65e470f480837be7f630896e91d0c61368b8a2f5
4
- data.tar.gz: 0c674e665f3f412f2181cde62163d116efbfc7de
3
+ metadata.gz: 320af9d1c2acc687468d82b303007b9a76ed6077
4
+ data.tar.gz: df304c796960d919f5e8e67978c374d9aa0d9d5d
5
5
  SHA512:
6
- metadata.gz: 487247e3185db46d245f2c7e78c43524ed4da61a200e92a2b9984ecab45bbf6db2eee009cc3b66239941af4bc3142944e97ca0ff4daad189966f31ab5a78b39e
7
- data.tar.gz: 92dfed70c63edf7436f4af7f1ec3b6bdb9e797fcfc953d2d74409cb8d70ed071b104e2bfdd9d597c8f004230f800120bc0ce3cc01f0eeb310ab3af14793db048
6
+ metadata.gz: afeab72e6cf3da5d2c0170ab2dad7bed50a0d87225ecc3ebdb72b03b46b036ccc1df320152241fb4f4b07a6cf09fb5bdc16061c1f4cdafd971bad16bc81784b3
7
+ data.tar.gz: 8748508ed16e390815b3f957a559c553f16a2505c8951e5f5dc21af06e15af87034e7529c0bf25a66b08992c10ef0d0b7d0503bc8b55f0c39645c526ca5d390b
@@ -1,6 +1,18 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
- == Development
3
+ == 1.5.6
4
+
5
+ Enhancements::
6
+
7
+ * Issue #167: Add support for Msc diagrams
8
+ * Issue #170: Add support for Syntrax diagrams
9
+ * Add support for SvgBob diagrams
10
+ * The output format can now be configured globally per diagram type using a document attribute with the name `<diagram_type>-format`.
11
+ As an example to generate all plantuml diagrams as SVG set the attribute `plantuml-format` to `svg` in your document header or via the command line.
12
+
13
+ Bug Fixes::
14
+
15
+ * Issue #164: Restore numbered captions for diagrams when using asciidoctor >= 1.5.6
4
16
 
5
17
  == 1.5.5
6
18
 
@@ -8,14 +20,19 @@ Enhancements::
8
20
 
9
21
  * Update PlantUML to revision 2017.15
10
22
  * Issue #147: Add support for PlantUML SVG output (@puffybsd)
11
- * Resolve compatibility issues with Asciidoctor 1.5.6 (@robertpanzer, @mojavelinux)
12
-
23
+
13
24
  Bug Fixes::
14
25
 
15
26
  * Issue #145: Incremental runs on documents containing meme diagrams would fail
16
27
  * Issue #150: Resolve Ditaa character encoding issues
17
28
  * Avoid error when the `PATH` environment variable is not defined (@BrentDouglas)
18
29
 
30
+ == 1.5.4.1
31
+
32
+ Enhancements::
33
+
34
+ * Resolve compatibility issues with Asciidoctor 1.5.6 (@robertpanzer, @mojavelinux)
35
+
19
36
  == 1.5.4
20
37
 
21
38
  Enhancements::
@@ -24,6 +24,7 @@ ifndef::env-site[:status:]
24
24
  :uri-imagemagick: http://www.imagemagick.org
25
25
  :uri-java: http://java.sun.com
26
26
  :uri-mermaid: http://knsv.github.io/mermaid/
27
+ :uri-mscgen: http://www.mcternan.me.uk/mscgen/
27
28
  :uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
28
29
  :uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
29
30
  :uri-phantomjs: http://phantomjs.org
@@ -32,6 +33,8 @@ ifndef::env-site[:status:]
32
33
  :uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
33
34
  :uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
34
35
  :uri-shaape: https://github.com/christiangoltz/shaape
36
+ :uri-svgbob: https://github.com/ivanceras/svgbobrus
37
+ :uri-syntrax: https://kevinpt.github.io/syntrax/
35
38
  :uri-umlet: http://www.umlet.com/
36
39
  :uri-wavedrom: http://wavedrom.com
37
40
  :uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
@@ -39,7 +42,7 @@ ifndef::env-site[:status:]
39
42
 
40
43
  Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
41
44
 
42
- The extensions support BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, GraphViz, Mermaid, PlantUML, Shaape and WaveDrom syntax.
45
+ The extensions supports the BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-ditaa}[Ditaa], {uri-erd}[Erd], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-svgbob}[SvgBob], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet] and {uri-wavedrom}[WaveDrom] syntax.
43
46
 
44
47
  Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
45
48
  The generated file is then inserted into your converted document.
@@ -114,12 +117,15 @@ The following diagram types and output formats are available:
114
117
  |{uri-dot}[graphviz] | |{check}|{check}|{check}|
115
118
  |<<meme,meme>> |{check}| |{check}| |
116
119
  |{uri-mermaid}[mermaid] | | |{check}|{check}|
120
+ |{uri-mscgen}[msc] | | |{check}|{check}|
117
121
  |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
118
122
  |{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
119
123
  |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
120
124
  |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
121
125
  |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
122
126
  |{uri-shaape}[shaape] | | |{check}|{check}|
127
+ |{uri-svgbob}[svgbob] | | | |{check}|
128
+ |{uri-syntrax}[syntrax] | |{check}|{check}|{check}|
123
129
  |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
124
130
  |{uri-wavedrom}[wavedrom] | | |{check}|{check}|
125
131
  |===
@@ -233,7 +239,7 @@ or load and register each extension individually.
233
239
  require 'asciidoctor-diagram/<extension_name>'
234
240
  ----
235
241
 
236
- `<extension_name>` can be one of `blockdiag`, `ditaa`, `erd`, `graphviz`, `meme`, `mermaid`, `plantuml`, `shaape`, or `wavedrom`.
242
+ `<extension_name>` can be one of `blockdiag`, `ditaa`, `erd`, `graphviz`, `meme`, `mermaid`, `msc`, `plantuml`, `shaape`, `svgbob`, `syntrax`, or `wavedrom`.
237
243
 
238
244
  Requiring one or more of these files will automatically register the extensions for all processed documents.
239
245
 
@@ -283,12 +289,15 @@ The following table lists the tools that are required for each diagram type, the
283
289
  |graphviz |{uri-graphviz}[GraphViz] |`dot` or `graphvizdot`
284
290
  |meme |{uri-imagemagick}[ImageMagick] |`convert` and `identify`
285
291
  |mermaid |{uri-mermaid}[Mermaid] |`mermaid`
292
+ |msc |{uri-mscgen}[Mscgen] |`mscgen`
286
293
  |nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
287
294
  |packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
288
295
  |plantuml |{uri-java}[Java] |`java`
289
296
  |rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
290
297
  |seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
291
298
  |shaape |{uri-shaape}[Shaape] |`shaape`
299
+ |svgbob |{uri-svgbob}[SvgBob] |`svgbob`
300
+ |syntrax |{uri-syntrax}[Syntrax] |`syntrax`
292
301
  |umlet |{uri-umlet}[Umlet] |`umlet`
293
302
  .2+|wavedrom |{uri-wavedromeditor}[WaveDrom Editor] |`wavedrom`
294
303
  |{uri-wavedromcli}[WaveDrom CLI] and {uri-phantomjs}[PhantomJS] |`wavedrom` and `phantomjs`
@@ -394,6 +403,14 @@ The attribute name at the block level should be prefixed with the name of the di
394
403
  |width |unspecified |The width of the generated image.
395
404
  |===
396
405
 
406
+ ==== Msc
407
+
408
+ [cols=">,<,<",options="header"]
409
+ |===
410
+ |Name |Default value |Description
411
+ |font |unspecified |The name of the font that should be used by mscgen
412
+ |===
413
+
397
414
  ==== PlantUML
398
415
 
399
416
  [cols=">,<,<",options="header"]
@@ -401,3 +418,13 @@ The attribute name at the block level should be prefixed with the name of the di
401
418
  |Name |Default value |Description
402
419
  |config |unspecified |Path to a config file to pass to PlantUML.
403
420
  |===
421
+
422
+ ==== Syntrax
423
+
424
+ [cols=">,<,<",options="header"]
425
+ |===
426
+ |Name |Default value |Description
427
+ |scale |1 |A scale factor that is applied to the image.
428
+ |style |unspecifed |Path to a style config file to pass to Syntrax.
429
+ |transparent |false |Makes the background of the image transparent instead of opaque white.
430
+ |===
data/Rakefile CHANGED
@@ -3,11 +3,6 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  test = RSpec::Core::RakeTask.new(:test)
5
5
 
6
- if ENV['APPVEYOR']
7
- # Exclude diagram types that require external libraries that are difficult to build on Windows.
8
- test.exclude_pattern = 'spec/**/{blockdiag,shaape}_spec.rb'
9
- end
10
-
11
6
  task :default => :test
12
7
 
13
8
  spec = Gem::Specification.load('asciidoctor-diagram.gemspec')
@@ -4,8 +4,11 @@ require_relative 'asciidoctor-diagram/erd'
4
4
  require_relative 'asciidoctor-diagram/graphviz'
5
5
  require_relative 'asciidoctor-diagram/meme'
6
6
  require_relative 'asciidoctor-diagram/mermaid'
7
+ require_relative 'asciidoctor-diagram/msc'
7
8
  require_relative 'asciidoctor-diagram/plantuml'
8
9
  require_relative 'asciidoctor-diagram/salt'
9
10
  require_relative 'asciidoctor-diagram/shaape'
11
+ require_relative 'asciidoctor-diagram/svgbob'
12
+ require_relative 'asciidoctor-diagram/syntrax'
10
13
  require_relative 'asciidoctor-diagram/umlet'
11
14
  require_relative 'asciidoctor-diagram/wavedrom'
@@ -100,13 +100,14 @@ module Asciidoctor
100
100
  include Which
101
101
 
102
102
  def blockdiag(tool, parent, source, format)
103
+ inherit_prefix = name
103
104
  cmd_name = tool.downcase
104
105
 
105
106
  # On Debian based systems the Python 3.x packages python3-(act|block|nw|seq)diag executables with
106
107
  # a '3' suffix.
107
108
  alt_cmd_name = "#{tool.downcase}3"
108
109
 
109
- font_path = source.attr('fontpath', nil, tool.downcase)
110
+ font_path = source.attr('fontpath', nil, inherit_prefix)
110
111
 
111
112
  generate_stdin(which(parent, cmd_name, :alt_cmds => [alt_cmd_name]), format.to_s, source.to_s) do |tool_path, output_path|
112
113
  args = [tool_path, '-a', '-o', Platform.native_path(output_path), "-T#{format.to_s}"]
@@ -98,7 +98,7 @@ module Asciidoctor
98
98
  def process(parent, reader_or_target, attributes)
99
99
  source = create_source(parent, reader_or_target, attributes.dup)
100
100
 
101
- format = source.attributes.delete('format') || self.class.default_format
101
+ format = source.attributes.delete('format') || source.attr('format', self.class.default_format, name)
102
102
  format = format.to_sym if format.respond_to?(:to_sym)
103
103
 
104
104
  raise "Format undefined" unless format
@@ -108,14 +108,21 @@ module Asciidoctor
108
108
  raise "#{self.class.name} does not support output format #{format}" unless generator_info
109
109
 
110
110
  begin
111
+ title = source.attributes.delete 'title'
112
+ caption = source.attributes.delete 'caption'
113
+
111
114
  case generator_info[:type]
112
115
  when :literal
113
- create_literal_block(parent, source, generator_info)
116
+ block = create_literal_block(parent, source, generator_info)
114
117
  else
115
- create_image_block(parent, source, format, generator_info)
118
+ block = create_image_block(parent, source, format, generator_info)
116
119
  end
120
+
121
+ block.title = title
122
+ block.assign_caption(caption, 'figure')
123
+ block
117
124
  rescue => e
118
- case parent.attr('diagram-on-error') || 'log'
125
+ case source.attr('on-error', 'log', 'diagram')
119
126
  when 'abort'
120
127
  raise e
121
128
  else
@@ -151,6 +158,8 @@ module Asciidoctor
151
158
  end
152
159
 
153
160
  private
161
+ DIGIT_CHAR_RANGE = ('0'.ord)..('9'.ord)
162
+
154
163
  def create_image_block(parent, source, format, generator_info)
155
164
  image_name = "#{source.image_name}.#{format}"
156
165
  image_dir = image_output_dir(parent)
@@ -210,6 +219,16 @@ module Asciidoctor
210
219
  'Diagram'
211
220
  end
212
221
 
222
+ image_attributes['alt'] = parent.sub_specialchars image_attributes['alt']
223
+
224
+ parent.document.register(:images, image_name)
225
+ if (scaledwidth = image_attributes['scaledwidth'])
226
+ # append % to scaledwidth if ends in number (no units present)
227
+ if DIGIT_CHAR_RANGE.include?((scaledwidth[-1] || 0).ord)
228
+ image_attributes['scaledwidth'] = %(#{scaledwidth}%)
229
+ end
230
+ end
231
+
213
232
  Asciidoctor::Block.new parent, :image, :content_model => :empty, :attributes => image_attributes
214
233
  end
215
234
 
@@ -384,8 +403,8 @@ module Asciidoctor
384
403
 
385
404
  if value.nil? && inherit
386
405
  case inherit
387
- when String
388
- value = @parent_block.attr("#{inherit}-#{name}", default_value, true)
406
+ when String, Symbol
407
+ value = @parent_block.attr("#{inherit.to_s}-#{name}", default_value, true)
389
408
  else
390
409
  value = @parent_block.attr(name, default_value, true)
391
410
  end
@@ -19,10 +19,12 @@ module Asciidoctor
19
19
  end
20
20
 
21
21
  def graphviz(parent, source, format)
22
+ inherit_prefix = name
23
+
22
24
  generate_stdin(which(parent, 'dot', :alt_attrs => ['graphvizdot']), format.to_s, source.to_s) do |tool_path, output_path|
23
25
  args = [tool_path, "-o#{Platform.native_path(output_path)}", "-T#{format.to_s}"]
24
26
 
25
- layout = source.attr('layout', nil, 'graphviz')
27
+ layout = source.attr('layout', nil, inherit_prefix)
26
28
  args << "-K#{layout}" if layout
27
29
 
28
30
  args
@@ -21,19 +21,20 @@ module Asciidoctor
21
21
  def meme(parent_block, source, format)
22
22
  convert = which(parent_block, 'convert')
23
23
  identify = which(parent_block, 'identify')
24
+ inherit_prefix = name
24
25
 
25
- bg_img = source.attr('background', nil, 'meme')
26
+ bg_img = source.attr('background', nil, inherit_prefix)
26
27
  raise "background attribute is required" unless bg_img
27
28
 
28
29
  bg_img = parent_block.normalize_system_path(bg_img, parent_block.attr('imagesdir'))
29
30
 
30
31
  top_label = source.attr('top')
31
32
  bottom_label = source.attr('bottom')
32
- fill_color = source.attr('fillColor', 'white', 'meme')
33
- stroke_color = source.attr('strokeColor', 'black', 'meme')
34
- stroke_width = source.attr('strokeWidth', '2', 'meme')
35
- font = source.attr('font', 'Impact', 'meme')
36
- options = source.attr('options', '', 'meme').split(',')
33
+ fill_color = source.attr('fillColor', 'white', inherit_prefix)
34
+ stroke_color = source.attr('strokeColor', 'black', inherit_prefix)
35
+ stroke_width = source.attr('strokeWidth', '2', inherit_prefix)
36
+ font = source.attr('font', 'Impact', inherit_prefix)
37
+ options = source.attr('options', '', inherit_prefix).split(',')
37
38
  noupcase = options.include?('noupcase')
38
39
 
39
40
  dimensions = Cli.run(identify, '-format', '%w %h', bg_img).match(/(?<w>\d+) (?<h>\d+)/)
@@ -20,27 +20,28 @@ module Asciidoctor
20
20
  end
21
21
 
22
22
  def mermaid(parent_block, source, format)
23
+ inherit_prefix = name
23
24
  mermaid = which(parent_block, 'mermaid')
24
25
  config['mermaid>=6'] ||= ::Asciidoctor::Diagram::Cli.run(mermaid, '--version').split('.')[0].to_i >= 6
25
26
  # Mermaid >= 6.0.0 requires PhantomJS 2.1; older version required 1.9
26
27
  phantomjs = which(parent_block, 'phantomjs', :alt_attrs => [config['mermaid>=6'] ? 'phantomjs_2' : 'phantomjs_19'])
27
28
 
28
- css = source.attr('css', nil, 'mermaid')
29
+ css = source.attr('css', nil, inherit_prefix)
29
30
  if css
30
31
  css = parent_block.normalize_system_path(css, source.base_dir)
31
32
  end
32
33
 
33
- gantt_config = source.attr('ganttConfig', nil, 'mermaid') || source.attr('ganttconfig', nil, 'mermaid')
34
+ gantt_config = source.attr('ganttConfig', nil, inherit_prefix) || source.attr('ganttconfig', nil, inherit_prefix)
34
35
  if gantt_config
35
36
  gantt_config = parent_block.normalize_system_path(gantt_config, source.base_dir)
36
37
  end
37
38
 
38
- seq_config = source.attr('sequenceConfig', nil, 'mermaid') || source.attr('sequenceconfig', nil, 'mermaid')
39
+ seq_config = source.attr('sequenceConfig', nil, inherit_prefix) || source.attr('sequenceconfig', nil, inherit_prefix)
39
40
  if seq_config
40
41
  seq_config = parent_block.normalize_system_path(seq_config, source.base_dir)
41
42
  end
42
43
 
43
- width = source.attr('width', nil, 'mermaid')
44
+ width = source.attr('width', nil, inherit_prefix)
44
45
 
45
46
  generate_file(mermaid, 'mmd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
46
47
  output_dir = File.dirname(output_path)
@@ -0,0 +1,8 @@
1
+ require_relative 'extensions'
2
+
3
+ Asciidoctor::Extensions.register do
4
+ require_relative 'msc/extension'
5
+
6
+ block Asciidoctor::Diagram::MscBlockProcessor, :msc
7
+ block_macro Asciidoctor::Diagram::MscBlockMacroProcessor, :msc
8
+ end
@@ -0,0 +1,44 @@
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 Mscgen
10
+ include CliGenerator
11
+ include Which
12
+
13
+ def self.included(mod)
14
+ [:png, :svg].each do |f|
15
+ mod.register_format(f, :image) do |parent, source|
16
+ mscgen(parent, source, f)
17
+ end
18
+ end
19
+ end
20
+
21
+ def mscgen(parent, source, format)
22
+ inherit_prefix = name
23
+ font = source.attr('font', nil, inherit_prefix)
24
+
25
+ generate_stdin(which(parent, 'mscgen'), format.to_s, source.to_s) do |tool_path, output_path|
26
+ args = [tool_path, '-o', Platform.native_path(output_path), '-T', format.to_s]
27
+ if font
28
+ args << '-F' << font
29
+ end
30
+ args << '-'
31
+ args
32
+ end
33
+ end
34
+ end
35
+
36
+ class MscBlockProcessor < Extensions::DiagramBlockProcessor
37
+ include Mscgen
38
+ end
39
+
40
+ class MscBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
41
+ include Mscgen
42
+ end
43
+ end
44
+ end
@@ -18,13 +18,14 @@ module Asciidoctor
18
18
  def plantuml(parent_block, source, tag, mime_type)
19
19
  Java.load
20
20
 
21
+ inherit_prefix = name
21
22
  code = preprocess_code(parent_block, source, tag)
22
23
 
23
24
  headers = {
24
25
  'Accept' => mime_type
25
26
  }
26
27
 
27
- config_file = source.attr('plantumlconfig', nil, true) || source.attr('config', nil, 'plantuml')
28
+ config_file = source.attr('plantumlconfig', nil, true) || source.attr('config', nil, inherit_prefix)
28
29
  if config_file
29
30
  headers['X-PlantUML-Config'] = File.expand_path(config_file, source.attr('docdir', nil, true))
30
31
  end
@@ -0,0 +1,8 @@
1
+ require_relative 'extensions'
2
+
3
+ Asciidoctor::Extensions.register do
4
+ require_relative 'svgbob/extension'
5
+
6
+ block Asciidoctor::Diagram::SvgBobBlockProcessor, :svgbob
7
+ block_macro Asciidoctor::Diagram::SvgBobBlockMacroProcessor, :svgbob
8
+ end
@@ -0,0 +1,38 @@
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 Svgbob
10
+ include CliGenerator
11
+ include Which
12
+
13
+ def self.included(mod)
14
+ [:svg].each do |f|
15
+ mod.register_format(f, :image) do |parent, source|
16
+ svgbob(parent, source, f)
17
+ end
18
+ end
19
+ end
20
+
21
+ def svgbob(parent, source, format)
22
+ inherit_prefix = name
23
+
24
+ generate_stdin(which(parent, 'svgbob'), format.to_s, source.to_s) do |tool_path, output_path|
25
+ [tool_path, '-o', Platform.native_path(output_path)]
26
+ end
27
+ end
28
+ end
29
+
30
+ class SvgBobBlockProcessor < Extensions::DiagramBlockProcessor
31
+ include Svgbob
32
+ end
33
+
34
+ class SvgBobBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
35
+ include Svgbob
36
+ end
37
+ end
38
+ end