kramdown-plantuml 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kramdown-plantuml.gemspec +1 -0
- data/lib/kramdown-plantuml/jekyll_provider.rb +16 -11
- data/lib/kramdown-plantuml/version.rb +1 -1
- data/lib/kramdown_html.rb +6 -3
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f873d08b8ab86ebe4ea964c30ad59a43a75c28d042d6627af1694d1ff262cbfd
|
4
|
+
data.tar.gz: cca59110bbdac25b41dc4c7ef41f9df0f84b17aa4a6da662feab19a73ca61724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbe10bc2e73c25b0a2bd09651e9bd73b2aeb612fa26f0470df0e9f0477c8f8f69f3c69d428b136826264e975068dc073724fcf4ab5e10b93e59585001983ada8
|
7
|
+
data.tar.gz: b74471596aadcf0bde3bf7878864918fb5bd6297172f69b5f9d30c214f84c1f67dfe2c11b7b6e1dc78bfb85c817c0a2c4a26e5bb9c420c519d490b5567b29fe8
|
data/kramdown-plantuml.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ['lib']
|
37
37
|
|
38
|
+
spec.add_dependency 'htmlentities', '~> 4'
|
38
39
|
spec.add_dependency 'kramdown', '~> 2.3'
|
39
40
|
spec.add_dependency 'kramdown-parser-gfm', '~> 1.1'
|
40
41
|
spec.add_dependency 'open3', '~> 0.1'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'English'
|
5
|
-
require '
|
5
|
+
require 'htmlentities'
|
6
6
|
require_relative 'log_wrapper'
|
7
7
|
require_relative 'diagram'
|
8
8
|
|
@@ -62,27 +62,32 @@ module Kramdown
|
|
62
62
|
html.gsub(/<!--#kramdown-plantuml\.start#-->(?<json>.*?)<!--#kramdown-plantuml\.end#-->/m) do
|
63
63
|
json = $LAST_MATCH_INFO[:json]
|
64
64
|
return replace_needle(json)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def replace_needle(json)
|
69
|
+
hash = JSON.parse(json)
|
70
|
+
options_hash = hash['options']
|
71
|
+
options = ::Kramdown::PlantUml::Options.new({ plantuml: options_hash })
|
72
|
+
|
73
|
+
begin
|
74
|
+
decode_and_convert(hash, options)
|
65
75
|
rescue StandardError => e
|
66
76
|
raise e if options.raise_errors?
|
67
77
|
|
68
|
-
logger.error
|
78
|
+
logger.error 'Error while replacing needle.'
|
79
|
+
logger.error e.to_s
|
80
|
+
logger.debug_multiline json
|
69
81
|
end
|
70
82
|
end
|
71
83
|
|
72
|
-
def
|
73
|
-
hash = JSON.parse(json)
|
84
|
+
def decode_and_convert(hash, options)
|
74
85
|
encoded_plantuml = hash['plantuml']
|
75
|
-
plantuml =
|
76
|
-
options = ::Kramdown::PlantUml::Options.new({ plantuml: hash['options'] })
|
86
|
+
plantuml = HTMLEntities.new.decode encoded_plantuml
|
77
87
|
diagram = ::Kramdown::PlantUml::Diagram.new(plantuml, options)
|
78
88
|
diagram.convert_to_svg
|
79
89
|
end
|
80
90
|
|
81
|
-
def decode_html_entities(encoded_plantuml)
|
82
|
-
doc = REXML::Document.new "<plantuml>#{encoded_plantuml}</plantuml>"
|
83
|
-
doc.root.text
|
84
|
-
end
|
85
|
-
|
86
91
|
def load_jekyll
|
87
92
|
require 'jekyll'
|
88
93
|
::Jekyll
|
data/lib/kramdown_html.rb
CHANGED
@@ -28,7 +28,7 @@ module Kramdown
|
|
28
28
|
options = ::Kramdown::PlantUml::Options.new(@options)
|
29
29
|
return jekyll.needle(element.value, options) if jekyll.installed?
|
30
30
|
|
31
|
-
convert_plantuml(element.value)
|
31
|
+
convert_plantuml(element.value, options)
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -37,10 +37,13 @@ module Kramdown
|
|
37
37
|
element.attr['class'] == 'language-plantuml'
|
38
38
|
end
|
39
39
|
|
40
|
-
def convert_plantuml(plantuml)
|
41
|
-
options = ::Kramdown::PlantUml::Options.new(@options)
|
40
|
+
def convert_plantuml(plantuml, options)
|
42
41
|
diagram = ::Kramdown::PlantUml::Diagram.new(plantuml, options)
|
43
42
|
diagram.convert_to_svg
|
43
|
+
rescue StandardError => e
|
44
|
+
raise e if options.raise_errors?
|
45
|
+
|
46
|
+
logger.error "Error while replacing needle: #{e.inspect}"
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swedbank Pay
|
@@ -10,6 +10,20 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: htmlentities
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: kramdown
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|