asciidoctor-mermaid 0.3.0 → 0.4.0

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
  SHA256:
3
- metadata.gz: 58b562bc72d72c35ead0c58aeac9854f338118dd827c511d8f93145c52f51ce7
4
- data.tar.gz: d4804028270f704bf76312b5383b49eb5428dbffed6cacb1568968ab907fabfd
3
+ metadata.gz: 577319efee650e33d1db7ee0a56917ae8b6107fdfaeee67ea9018a857c189529
4
+ data.tar.gz: 5c2df794560ef01598f5dd475310e894a9f68bd60b4b0a20d4acaf870536180c
5
5
  SHA512:
6
- metadata.gz: b777dd329e10488527dce93d7e02603850b2bec4ba1504215a22a6401d224c9872ce4c3e1602333ab7a27b989379f1ec55b2e2beb0d47480f9683c690319bf8a
7
- data.tar.gz: ee96b36f01f0983e61ebe541c640d881f6ca68edcce4cc3e615f23dbf8ba13580d5dc7dcd86d19372e3ce99cc2a06576d4d77e99d2c30614cc9b8353bd5aa997
6
+ metadata.gz: 3996fb7d9d1c3a15a0013489763154ee68881a05a5f1e67d3f0a9d31310899ed717f201e33edd835154022edad3be3b5592b8db0fc70b1fa6514f78641eb8cab
7
+ data.tar.gz: 12a5dc56e46770bb26b41fb2b800fc5314d05b67b7d7a42ad62c41a4dedf7ac232ee930c0b298eb07b8001ad43cec17d651338549631c70ae264d795082677de
@@ -6,9 +6,10 @@ require_relative 'cli'
6
6
  class MermaidTreeProcessor < Asciidoctor::Extensions::TreeProcessor
7
7
  def process(document)
8
8
  document.blocks.map! do |block|
9
- if !block.blocks.empty?
9
+ if block.respond_to?(:blocks) && !block.blocks.empty?
10
10
  process(block)
11
- elsif block.attributes['style'] === 'source' &&
11
+ elsif block.respond_to?(:attributes) &&
12
+ block.attributes['style'] === 'source' &&
12
13
  block.attributes['language'] === 'mermaid'
13
14
  self.convert_block(block)
14
15
  else
@@ -4,12 +4,13 @@ require 'digest/md5'
4
4
  require 'tempfile'
5
5
  require_relative 'cli'
6
6
 
7
- class MermaidTreeProcessor < Asciidoctor::Extensions::TreeProcessor
7
+ class MermaidPDFTreeProcessor < Asciidoctor::Extensions::TreeProcessor
8
8
  def process(document)
9
9
  document.blocks.map! do |block|
10
- if !block.blocks.empty?
10
+ if block.respond_to?(:blocks) && !block.blocks.empty?
11
11
  process(block)
12
- elsif block.attributes['style'] === 'source' &&
12
+ elsif block.respond_to?(:attributes) &&
13
+ block.attributes['style'] === 'source' &&
13
14
  block.attributes['language'] === 'mermaid'
14
15
  self.convert_block(block)
15
16
  else
@@ -41,4 +42,4 @@ class MermaidTreeProcessor < Asciidoctor::Extensions::TreeProcessor
41
42
  end
42
43
  end
43
44
 
44
- Asciidoctor::Extensions.register { treeprocessor MermaidTreeProcessor }
45
+ Asciidoctor::Extensions.register { treeprocessor MermaidPDFTreeProcessor }
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Mermaid
3
- VERSION = '0.3.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require 'asciidoctor'
2
+ require 'asciidoctor-mermaid'
2
3
 
3
4
  mermaid_doc = <<-eos
4
5
  lorem ipsum
@@ -9,14 +10,37 @@ flowchart LR
9
10
  ```
10
11
  eos
11
12
 
13
+ array_handling = <<-eos
14
+ [glossary]
15
+ == Glossary
16
+
17
+ - [[g-foo, FOO]]
18
+ FOO::
19
+
20
+ This is the first entry
21
+
22
+ - [[g-bar, BAR]]
23
+ BAR::
24
+
25
+ This is the second entry
26
+ eos
27
+
12
28
  describe 'extension' do
13
29
  before do
14
30
  Asciidoctor::Extensions.unregister_all
15
- require 'asciidoctor-mermaid'
31
+ Asciidoctor::Extensions.register { treeprocessor MermaidTreeProcessor }
16
32
  end
33
+
17
34
  it 'renders a basic mermaid diagram' do
18
35
  doc = Asciidoctor.convert mermaid_doc
19
36
  expect(doc).to include('id="mermaid-')
20
37
  expect(doc).to include('flowchart node text')
21
38
  end
39
+
40
+ # On v0.3.0 this should fail with NoMethodError: undefined method `blocks' for #<Array...>
41
+ it 'renders a document containing arrays' do
42
+ doc = Asciidoctor.convert array_handling
43
+ expect(doc).to include('FOO')
44
+ expect(doc).to include('BAR')
45
+ end
22
46
  end
@@ -1,4 +1,5 @@
1
1
  require 'asciidoctor'
2
+ require 'asciidoctor-mermaid/pdf'
2
3
 
3
4
  mermaid_doc = <<-eos
4
5
  lorem ipsum
@@ -9,14 +10,37 @@ flowchart LR
9
10
  ```
10
11
  eos
11
12
 
13
+ array_handling = <<-eos
14
+ [glossary]
15
+ == Glossary
16
+
17
+ - [[g-foo, FOO]]
18
+ FOO::
19
+
20
+ This is the first entry
21
+
22
+ - [[g-bar, BAR]]
23
+ BAR::
24
+
25
+ This is the second entry
26
+ eos
27
+
12
28
  describe 'pdf extension' do
13
29
  before do
14
30
  Asciidoctor::Extensions.unregister_all
15
- require 'asciidoctor-mermaid/pdf'
31
+ Asciidoctor::Extensions.register { treeprocessor MermaidPDFTreeProcessor }
16
32
  end
33
+
17
34
  it 'renders a basic mermaid diagram' do
18
35
  doc = Asciidoctor.convert mermaid_doc
19
36
  expect(doc).to include('class="imageblock text-center"')
20
37
  expect(doc).to include('<img src=')
21
38
  end
39
+
40
+ # On v0.3.0 this should fail with NoMethodError: undefined method `blocks' for #<Array...>
41
+ it 'renders a document containing arrays' do
42
+ doc = Asciidoctor.convert array_handling
43
+ expect(doc).to include('FOO')
44
+ expect(doc).to include('BAR')
45
+ end
22
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-mermaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Bennett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-03 00:00:00.000000000 Z
11
+ date: 2022-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler