kramdown-rfc2629 1.3.3 → 1.3.8
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/data/kramdown-rfc2629.erb +14 -3
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +49 -6
- 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: 0bf90a7fd57ee1492ceaf533983659336ca24c1334b79cd9be55661c4622d10f
|
4
|
+
data.tar.gz: 940584f0bea9de4fb1e2e9b91a79bd8b4eb0192543f625d7c0cbfa9858402275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f444f161ab0611bc92bbdb2f790c13f1676b9e035368fbcd7869317e5f30b28dd3e59789e55c0c6e3f67f5f8d4d5fa3d2368b26e307ab44f2e846604670754ab
|
7
|
+
data.tar.gz: dfcae66926b4a96424d0be1144d7ccf5c00a28b5153d2adf5897484b9f51826989bf14314909e7a3327ad9ac75b9b57f63270626890b7de3648ddbf2d63e2c5d
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -43,9 +43,20 @@
|
|
43
43
|
</abstract>
|
44
44
|
|
45
45
|
<% sechash.keys.each do |k| -%>
|
46
|
-
<% if k =~ /\
|
47
|
-
|
48
|
-
|
46
|
+
<% if k =~ /\A(to_be_removed_)?note_(.*)/ -%>
|
47
|
+
|
48
|
+
<% option = ""
|
49
|
+
text = ""
|
50
|
+
if $1
|
51
|
+
if $options.v3
|
52
|
+
option = " removeInRFC=\"true\""
|
53
|
+
else
|
54
|
+
text = " <t>[This note is to be removed before publishing as an RFC.]</t>\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
-%>
|
58
|
+
<note title="<%= $2.gsub("_", " ")%>"<%= option %>>
|
59
|
+
<%= text -%>
|
49
60
|
|
50
61
|
<%= sechash.delete(k) -%>
|
51
62
|
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.3.
|
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.}
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -150,6 +150,31 @@ 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
|
+
|
168
|
+
def svg_clean(s) # expensive, risky
|
169
|
+
require "rexml/document"
|
170
|
+
d = REXML::Document.new(s)
|
171
|
+
REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil } #; warn x.inspect }
|
172
|
+
REXML::XPath.each(d.root, "//*[@text-rendering]") { |x| x.attributes["text-rendering"] = 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) }
|
175
|
+
d.to_s
|
176
|
+
end
|
177
|
+
|
153
178
|
def convert_codeblock(el, indent, opts)
|
154
179
|
# el.attr['anchor'] ||= saner_generate_id(el.value) -- no longer in 1.0.6
|
155
180
|
result = el.value
|
@@ -194,12 +219,26 @@ module Kramdown
|
|
194
219
|
end
|
195
220
|
end
|
196
221
|
case t
|
197
|
-
when "goat"
|
222
|
+
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt"
|
198
223
|
require 'tempfile'
|
199
224
|
file = Tempfile.new("kramdown-rfc")
|
200
225
|
file.write(result)
|
201
226
|
file.close
|
202
|
-
|
227
|
+
case t
|
228
|
+
when "goat"
|
229
|
+
result1, _s = Open3.capture2("goat #{file.path}", stdin_data: result);
|
230
|
+
when "ditaa" # XXX: This needs some form of option-setting
|
231
|
+
result1, _s = Open3.capture2("ditaa #{file.path} --svg -o -", stdin_data: result);
|
232
|
+
result1 = svg_clean(result1)
|
233
|
+
when "mscgen"
|
234
|
+
result1, _s = Open3.capture2("mscgen -T svg -i #{file.path} -o -", stdin_data: result);
|
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"
|
241
|
+
end
|
203
242
|
# warn ["goat:", result1.inspect]
|
204
243
|
file.unlink
|
205
244
|
result1, _s = Open3.capture2("svgcheck -qa", stdin_data: result1);
|
@@ -477,7 +516,8 @@ module Kramdown
|
|
477
516
|
end
|
478
517
|
end
|
479
518
|
end
|
480
|
-
rescue OpenURI::HTTPError,
|
519
|
+
rescue OpenURI::HTTPError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
520
|
+
SocketError, Timeout::Error => e
|
481
521
|
warn "*** #{e} while fetching #{url}"
|
482
522
|
end
|
483
523
|
end
|
@@ -485,7 +525,7 @@ module Kramdown
|
|
485
525
|
begin
|
486
526
|
File.read(fn) # this blows up if no cache available after fetch attempt
|
487
527
|
rescue Errno::ENOENT => e
|
488
|
-
warn "*** #{e} for
|
528
|
+
warn "*** #{e} for #{fn}"
|
489
529
|
end
|
490
530
|
end
|
491
531
|
|
@@ -537,7 +577,7 @@ module Kramdown
|
|
537
577
|
fn = "reference.#{t}.#{n}.xml"
|
538
578
|
sub, ttl, can_anchor = XML_RESOURCE_ORG_MAP[t]
|
539
579
|
ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
|
540
|
-
puts "Huh:
|
580
|
+
puts "*** Huh: #{fn}" unless sub
|
541
581
|
url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
|
542
582
|
if can_anchor # create anchor server-side for stand_alone: false
|
543
583
|
url << "?anchor=#{anchor}"
|
@@ -547,7 +587,10 @@ module Kramdown
|
|
547
587
|
to_insert.scrub! rescue nil # only do this for Ruby >= 2.1
|
548
588
|
# this may be a bit controversial: Don't break the build if reference is broken
|
549
589
|
if KRAMDOWN_OFFLINE
|
550
|
-
to_insert
|
590
|
+
unless to_insert
|
591
|
+
to_insert = "<reference anchor='#{anchor}'> <front> <title>*** BROKEN REFERENCE ***</title> <author> <organization/> </author> <date/> </front> </reference>"
|
592
|
+
warn "*** KRAMDOWN_OFFLINE: Inserting broken reference for #{fn}"
|
593
|
+
end
|
551
594
|
else
|
552
595
|
exit 66 unless to_insert # EX_NOINPUT
|
553
596
|
end
|
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.
|
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-
|
11
|
+
date: 2020-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|