asciidoctor-mermaid 0.4.0 → 0.4.1
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/lib/asciidoctor-mermaid/pdf.rb +9 -5
- data/lib/asciidoctor-mermaid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6275fc0501bbfa03f17c82eb2dd86b750ca881042b2c749e614b1d046e440d33
|
4
|
+
data.tar.gz: 348cd60e6d9f67ff5a2537fcddf70b542e6937f87785def52cefd002baeb4197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
27
|
-
|
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' =>
|
32
|
+
'target' => image_contents,
|
33
33
|
'align' => 'center',
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
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
|
-
|
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
|
|
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.
|
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-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|