kramdown-plantuml 1.2.0 → 1.3.0

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: 22eb0afc1243816120df8e8acfcf9344e652f376b5b3b06a30bf9ad5968977d5
4
- data.tar.gz: ba1ddb45bb16802cd21b4e138a2914b56c7d8405edbaec0c17dbdef0da2a9843
3
+ metadata.gz: bc1234f77cba369797da8b8efd79b0a1913e65cd07f14ab26189c0acb2fa4900
4
+ data.tar.gz: 445fea556a2c3f248a3158e3f8fd9383624a1aceefb1e03e549e48ce87a6a4de
5
5
  SHA512:
6
- metadata.gz: 715ab104a048c524ef11da13d607e8701f90b6125bbcf251688204ad8011c46f673a94e188c23b5635a01c0af7f057e7d077e62df4d405d9353ac9df5a403ffc
7
- data.tar.gz: cc532b7f4548e2a457971e4267113976d5422ce9772fae2ba71f7480a81e1d80dc1f752bcd2a979387e18024cb9a89b2bab55b043e539f31b15d9e7834083dfc
6
+ metadata.gz: 62dea36dfd6f811cb0861db862a938ae6e10f4d36fa1783ef33ec2338355710cfe8c718fcaf246cc73974d652729ea99560220997ef12c44174a8b6b1adbab1b
7
+ data.tar.gz: b9b72275e8eec577c9a249802191f8e9a457b1dfdb4e83328e2e4a942f43077ab39c08fbff2790af23f7c1c3c6d451250bfab7effa7b47455d994472bea1c439
data/README.md CHANGED
@@ -132,20 +132,26 @@ kramdown:
132
132
 
133
133
  ### Dimensions and Styling
134
134
 
135
- It's possible to customize the dimensions of the diagram by providing the
136
- `width` and `height` configuration keys. It's also possible to add arbitrary
137
- styling with the `style` key.
135
+ It's possible to customize the dimensions and scale of the diagram by providing
136
+ the `width`, `height` and `scale` configuration keys. It's also possible to add
137
+ arbitrary styling with the `style` key.
138
+
139
+ `scale` is applied before the diagram is generated, while `width` and `height`
140
+ are applied after, meaning they can be combined (to most likely detrimental
141
+ results, but YOLO).
138
142
 
139
143
  ```yaml
140
144
  kramdown:
141
145
  plantuml:
142
146
  width: 200px
143
147
  height: 100px
148
+ scale: 2
144
149
  style: "border: 1px solid black"
145
150
  ```
146
151
 
147
152
  To remove the `width`, `height` and `style` attributes from the `<svg />`
148
- element, set the key's value to `none`.
153
+ element, set the key's value to `none`. `scale` does not support a value of
154
+ `none` as it does not need to be removed.
149
155
 
150
156
  ```yaml
151
157
  kramdown:
@@ -7,7 +7,7 @@ module Kramdown
7
7
  module PlantUml
8
8
  # Options for PlantUML processing
9
9
  class Options
10
- attr_reader :theme_name, :theme_directory, :width, :height, :style
10
+ attr_reader :theme_name, :theme_directory, :width, :height, :style, :scale
11
11
 
12
12
  def initialize(options_hash = {})
13
13
  @logger = LogWrapper.init
@@ -72,14 +72,15 @@ module Kramdown
72
72
  set_instance_property(:width, options)
73
73
  set_instance_property(:height, options)
74
74
  set_instance_property(:style, options)
75
+ set_instance_property(:scale, options)
75
76
  end
76
77
 
77
- def set_instance_property(name, options)
78
- return unless options.key? name
78
+ def set_instance_property(key, options)
79
+ return unless options.key? key
79
80
 
80
- value = options[name]
81
+ value = options[key]
81
82
  value = :none if value.none_s?
82
- prop_name = "@#{name}".to_sym
83
+ prop_name = "@#{key}".to_sym
83
84
  instance_variable_set(prop_name, value)
84
85
  end
85
86
 
@@ -30,7 +30,7 @@ module Kramdown
30
30
  return @svg_diagram unless @svg_diagram.nil?
31
31
 
32
32
  @plantuml = @theme.apply(@plantuml)
33
- log(plantuml)
33
+ log(@plantuml)
34
34
  @result = @executor.execute(self)
35
35
  @svg_diagram = SvgDiagram.new(@result)
36
36
  rescue StandardError => e
@@ -8,7 +8,7 @@ module Kramdown
8
8
  module PlantUml
9
9
  # Provides theming support for PlantUML
10
10
  class Theme
11
- attr_reader :name, :directory
11
+ attr_reader :name, :directory, :scale
12
12
 
13
13
  def initialize(options)
14
14
  raise ArgumentError, 'options cannot be nil' if options.nil?
@@ -17,6 +17,7 @@ module Kramdown
17
17
  @raise_errors = options.raise_errors?
18
18
  @logger = LogWrapper.init
19
19
  @name = options.theme_name
20
+ @scale = options.scale
20
21
  @directory = resolve options.theme_directory
21
22
  end
22
23
 
@@ -26,11 +27,6 @@ module Kramdown
26
27
  return plantuml
27
28
  end
28
29
 
29
- if @name.nil? || @name.empty?
30
- @logger.debug 'No theme to apply.'
31
- return plantuml.strip
32
- end
33
-
34
30
  theme(plantuml)
35
31
  end
36
32
 
@@ -59,13 +55,12 @@ module Kramdown
59
55
  end
60
56
 
61
57
  def theme(plantuml)
62
- startuml = '@startuml'
63
- startuml_index = plantuml.index(startuml) + startuml.length
58
+ theme_string = build_theme_string
64
59
 
65
- return plantuml if startuml_index.nil?
66
-
67
- theme_string = "\n!theme #{@name}"
68
- theme_string << " from #{@directory}" unless @directory.nil?
60
+ if theme_string.empty?
61
+ @logger.debug 'No theme to apply.'
62
+ return plantuml
63
+ end
69
64
 
70
65
  @logger.debug "Applying #{theme_string.strip}"
71
66
 
@@ -75,6 +70,18 @@ module Kramdown
75
70
 
76
71
  plantuml.strip
77
72
  end
73
+
74
+ def build_theme_string
75
+ theme_string = ''
76
+
77
+ unless @name.nil? || @name.empty?
78
+ theme_string << "\n!theme #{@name}"
79
+ theme_string << " from #{@directory}" unless @directory.nil?
80
+ end
81
+
82
+ theme_string << "\nscale #{@scale}" unless @scale.nil?
83
+ theme_string
84
+ end
78
85
  end
79
86
  end
80
87
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kramdown
4
4
  module PlantUml
5
- VERSION = '1.2.0'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-plantuml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swedbank Pay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -194,7 +194,7 @@ files:
194
194
  - LICENSE
195
195
  - README.md
196
196
  - Rakefile
197
- - bin/net/sourceforge/plantuml/plantuml/1.2021.14/plantuml-1.2021.14.jar
197
+ - bin/net/sourceforge/plantuml/plantuml/1.2021.12/plantuml-1.2021.12.jar
198
198
  - kramdown-plantuml.gemspec
199
199
  - lib/kramdown-plantuml.rb
200
200
  - lib/kramdown-plantuml/bool_env.rb