asciidoctor-mermaid 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 577319efee650e33d1db7ee0a56917ae8b6107fdfaeee67ea9018a857c189529
4
- data.tar.gz: 5c2df794560ef01598f5dd475310e894a9f68bd60b4b0a20d4acaf870536180c
3
+ metadata.gz: 6275fc0501bbfa03f17c82eb2dd86b750ca881042b2c749e614b1d046e440d33
4
+ data.tar.gz: 348cd60e6d9f67ff5a2537fcddf70b542e6937f87785def52cefd002baeb4197
5
5
  SHA512:
6
- metadata.gz: 3996fb7d9d1c3a15a0013489763154ee68881a05a5f1e67d3f0a9d31310899ed717f201e33edd835154022edad3be3b5592b8db0fc70b1fa6514f78641eb8cab
7
- data.tar.gz: 12a5dc56e46770bb26b41fb2b800fc5314d05b67b7d7a42ad62c41a4dedf7ac232ee930c0b298eb07b8001ad43cec17d651338549631c70ae264d795082677de
6
+ metadata.gz: c834f88d3e763e66898b88a316516087b001025cefe690aa85a1c4892dd1f6ff23d6c0c6fadd44b47e850bc193aed4a6141dc48c1a1b1aca58aa09d4d277739c
7
+ data.tar.gz: 57bfc15c788c8d0b0b5de8f36e461c26ef2e862faa7519e80f59dce08917aa9ddad1ec7c556a43d4d179c6d8a909a9e4888b3d1413e913cc902a0155bdacd8e3
@@ -23,22 +23,26 @@ class MermaidPDFTreeProcessor < Asciidoctor::Extensions::TreeProcessor
23
23
  protected
24
24
 
25
25
  def convert_block(block)
26
- # TODO: Currently I'm unsure how to clean up tmp images after pdf generation completes
27
- img = self.render_svg(block.source)
26
+ image_contents = "data:image/png;base64," + Base64.strict_encode64(self.render_png(block.source))
27
+
28
28
  Asciidoctor::Block.new block.parent,
29
29
  :image,
30
30
  attributes: {
31
31
  'imagesdir' => nil,
32
- 'target' => img.path,
32
+ 'target' => image_contents,
33
33
  'align' => 'center',
34
34
  }
35
35
  end
36
36
 
37
- def render_svg(content)
37
+ def render_png(content)
38
38
  file_name = Digest::MD5.hexdigest(content)
39
39
  output_file = Tempfile.new([file_name, '.png'])
40
40
  ::Asciidoctor::Mermaid::Cli.run(content, "-o#{output_file.path}")
41
- output_file
41
+
42
+ # Tempfile will unlink the underlying PDF by the time bundling occurs. Therefore we need to
43
+ # read back in the data so that we can tell Asciidoctor to use an inline data uri.
44
+ # TODO: Does this event need to use a tmp file? Can mmdc return the contents directly?
45
+ File.read(output_file.path)
42
46
  end
43
47
  end
44
48
 
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Mermaid
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  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.4.0
4
+ version: 0.4.1
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-24 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler