kramdown-rfc2629 1.3.7 → 1.3.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: 6b34bf25043259c59faad1a28e37420d84708298d7d1132954855e9bc9f80469
4
- data.tar.gz: 598bdd61e5206c389e32e8014469688f516abf4c3b965fc8c14ddd9f10210d63
3
+ metadata.gz: 0bf90a7fd57ee1492ceaf533983659336ca24c1334b79cd9be55661c4622d10f
4
+ data.tar.gz: 940584f0bea9de4fb1e2e9b91a79bd8b4eb0192543f625d7c0cbfa9858402275
5
5
  SHA512:
6
- metadata.gz: ef912cb94fce48cb61f0a352d9a2b0c701eb9c8149fe46608fdff508f2e974289a777d773a5a95dbc433c7cfbbd667aacf0391b68371aa549baabf75a325890d
7
- data.tar.gz: c54c3cc14bdefcbae8a9650522653851af06b9c054ac239eb0555714c85fe5dd14e03fa5d16836c6e12ee83a559ed808c4c4e79d8665592966688f5b6fcba5bd
6
+ metadata.gz: f444f161ab0611bc92bbdb2f790c13f1676b9e035368fbcd7869317e5f30b28dd3e59789e55c0c6e3f67f5f8d4d5fa3d2368b26e307ab44f2e846604670754ab
7
+ data.tar.gz: dfcae66926b4a96424d0be1144d7ccf5c00a28b5153d2adf5897484b9f51826989bf14314909e7a3327ad9ac75b9b57f63270626890b7de3648ddbf2d63e2c5d
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.7'
3
+ s.version = '1.3.8'
4
4
  s.summary = "Kramdown extension for generating RFC 7749 XML."
5
5
  s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
6
6
  "kramdown" markdown parser. Mostly useful for RFC writers.}
@@ -150,13 +150,28 @@ module Kramdown
150
150
  generate_id(value).gsub(/-+/, '-')
151
151
  end
152
152
 
153
+ def svg_munch_color(c, fill)
154
+ case c
155
+ when /\A#(..)(..)(..)\z/
156
+ if [$1, $2, $3].map {|x| x.to_i(16)}.sum >= 300 # arbitrary
157
+ 'white'
158
+ else
159
+ 'black'
160
+ end
161
+ when 'none'
162
+ 'none' if fill # delete for stroke
163
+ else
164
+ c
165
+ end
166
+ end
167
+
153
168
  def svg_clean(s) # expensive, risky
154
169
  require "rexml/document"
155
170
  d = REXML::Document.new(s)
156
171
  REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil } #; warn x.inspect }
157
172
  REXML::XPath.each(d.root, "//*[@text-rendering]") { |x| x.attributes["text-rendering"] = nil } #; warn x.inspect }
158
- REXML::XPath.each(d.root, "//*[@stroke='#000000']") { |x| x.attributes["stroke"] = "black" } #; warn x.inspect }
159
- REXML::XPath.each(d.root, "//*[@stroke='none']") { |x| x.attributes["stroke"] = nil } #; warn x.inspect }
173
+ REXML::XPath.each(d.root, "//*[@stroke]") { |x| x.attributes["stroke"] = svg_munch_color(x.attributes["stroke"], false) }
174
+ REXML::XPath.each(d.root, "//*[@fill]") { |x| x.attributes["fill"] = svg_munch_color(x.attributes["fill"], true) }
160
175
  d.to_s
161
176
  end
162
177
 
@@ -204,7 +219,7 @@ module Kramdown
204
219
  end
205
220
  end
206
221
  case t
207
- when "goat", "ditaa", "mscgen"
222
+ when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt"
208
223
  require 'tempfile'
209
224
  file = Tempfile.new("kramdown-rfc")
210
225
  file.write(result)
@@ -218,6 +233,11 @@ module Kramdown
218
233
  when "mscgen"
219
234
  result1, _s = Open3.capture2("mscgen -T svg -i #{file.path} -o -", stdin_data: result);
220
235
  result1 = svg_clean(result1)
236
+ when "plantuml", "plantuml-utxt"
237
+ plantuml = "@startuml\n#{result}\n@enduml"
238
+ result1, _s = Open3.capture2("plantuml -pipe -tsvg", stdin_data: plantuml);
239
+ result1 = svg_clean(result1)
240
+ result, _s = Open3.capture2("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
221
241
  end
222
242
  # warn ["goat:", result1.inspect]
223
243
  file.unlink
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-30 00:00:00.000000000 Z
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown