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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 178996116d7a833c324db54da1b3c367fe13c1d55fabc47026df12bec25b6f9d
4
- data.tar.gz: d5dc3e4824ab5095b42b33e4b01cc6cb38735fe0bb220472f02e8014f069261b
3
+ metadata.gz: f873d08b8ab86ebe4ea964c30ad59a43a75c28d042d6627af1694d1ff262cbfd
4
+ data.tar.gz: cca59110bbdac25b41dc4c7ef41f9df0f84b17aa4a6da662feab19a73ca61724
5
5
  SHA512:
6
- metadata.gz: 5dd2e36fc7b66a4a8948ba801d75107c04fedbbb612fe525cabac758de15e3908368999d8779126a082dfcef70f990194c3abf0bace90eea019b182e3d26626c
7
- data.tar.gz: 166be327fab188558c365c5284739d57ed7b851ce953e616b98d7f9002a20f89ab6af7527134a148eefdf547c4465adfe469d597eb8919af26a51cf3615e2b57
6
+ metadata.gz: bbe10bc2e73c25b0a2bd09651e9bd73b2aeb612fa26f0470df0e9f0477c8f8f69f3c69d428b136826264e975068dc073724fcf4ab5e10b93e59585001983ada8
7
+ data.tar.gz: b74471596aadcf0bde3bf7878864918fb5bd6297172f69b5f9d30c214f84c1f67dfe2c11b7b6e1dc78bfb85c817c0a2c4a26e5bb9c420c519d490b5567b29fe8
@@ -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 'rexml/document'
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 "Error while replacing needle: #{e.inspect}"
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 replace_needle(json)
73
- hash = JSON.parse(json)
84
+ def decode_and_convert(hash, options)
74
85
  encoded_plantuml = hash['plantuml']
75
- plantuml = decode_html_entities(encoded_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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kramdown
4
4
  module PlantUml
5
- VERSION = '1.1.7'
5
+ VERSION = '1.1.8'
6
6
  end
7
7
  end
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.7
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