kramdown-rfc2629 1.3.2 → 1.3.7
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/bin/kdrfc +11 -4
- data/data/kramdown-rfc2629.erb +14 -3
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +29 -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: 6b34bf25043259c59faad1a28e37420d84708298d7d1132954855e9bc9f80469
|
4
|
+
data.tar.gz: 598bdd61e5206c389e32e8014469688f516abf4c3b965fc8c14ddd9f10210d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef912cb94fce48cb61f0a352d9a2b0c701eb9c8149fe46608fdff508f2e974289a777d773a5a95dbc433c7cfbbd667aacf0391b68371aa549baabf75a325890d
|
7
|
+
data.tar.gz: c54c3cc14bdefcbae8a9650522653851af06b9c054ac239eb0555714c85fe5dd14e03fa5d16836c6e12ee83a559ed808c4c4e79d8665592966688f5b6fcba5bd
|
data/bin/kdrfc
CHANGED
@@ -96,6 +96,9 @@ op = OptionParser.new do |opts|
|
|
96
96
|
opts.on("-x", "--[no-]xml", "Convert to xml only") do |v|
|
97
97
|
$options.xml_only = v
|
98
98
|
end
|
99
|
+
opts.on("-p", "--[no-]prep", "Convert xml to prepped xml") do |v|
|
100
|
+
$options.prep = v
|
101
|
+
end
|
99
102
|
opts.on("-h", "--[no-]html", "Convert to html as well") do |v|
|
100
103
|
$options.html = v
|
101
104
|
end
|
@@ -108,6 +111,12 @@ op = OptionParser.new do |opts|
|
|
108
111
|
end
|
109
112
|
op.parse!
|
110
113
|
|
114
|
+
def process_the_xml(fn, base)
|
115
|
+
process_xml(fn, "#{base}.prepped.xml", "--preptool") if $options.prep
|
116
|
+
process_xml(fn, "#{base}.txt") if $options.txt
|
117
|
+
process_xml(fn, "#{base}.html", "--html") if $options.html
|
118
|
+
end
|
119
|
+
|
111
120
|
case ARGV.size
|
112
121
|
when 1
|
113
122
|
fn = ARGV[0]
|
@@ -116,14 +125,12 @@ when 1
|
|
116
125
|
if $options.xml_only
|
117
126
|
warn "*** You already have XML"
|
118
127
|
else # FIXME: copy/paste
|
119
|
-
|
120
|
-
process_xml(fn, "#$1.html", "--html") unless $options.xml_only or not $options.html
|
128
|
+
process_the_xml(fn, $1)
|
121
129
|
end
|
122
130
|
when /(.*)\.mk?d\z/
|
123
131
|
xml = "#$1.xml"
|
124
132
|
process_mkd(fn, xml)
|
125
|
-
|
126
|
-
process_xml(xml, "#$1.html", "--html") unless $options.xml_only or not $options.html
|
133
|
+
process_the_xml(xml, $1) unless $options.xml_only
|
127
134
|
else
|
128
135
|
warn "Unknown file type: #{fn}"
|
129
136
|
exit 1
|
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.7'
|
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,16 @@ module Kramdown
|
|
150
150
|
generate_id(value).gsub(/-+/, '-')
|
151
151
|
end
|
152
152
|
|
153
|
+
def svg_clean(s) # expensive, risky
|
154
|
+
require "rexml/document"
|
155
|
+
d = REXML::Document.new(s)
|
156
|
+
REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil } #; warn x.inspect }
|
157
|
+
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 }
|
160
|
+
d.to_s
|
161
|
+
end
|
162
|
+
|
153
163
|
def convert_codeblock(el, indent, opts)
|
154
164
|
# el.attr['anchor'] ||= saner_generate_id(el.value) -- no longer in 1.0.6
|
155
165
|
result = el.value
|
@@ -194,12 +204,21 @@ module Kramdown
|
|
194
204
|
end
|
195
205
|
end
|
196
206
|
case t
|
197
|
-
when "goat"
|
207
|
+
when "goat", "ditaa", "mscgen"
|
198
208
|
require 'tempfile'
|
199
209
|
file = Tempfile.new("kramdown-rfc")
|
200
210
|
file.write(result)
|
201
211
|
file.close
|
202
|
-
|
212
|
+
case t
|
213
|
+
when "goat"
|
214
|
+
result1, _s = Open3.capture2("goat #{file.path}", stdin_data: result);
|
215
|
+
when "ditaa" # XXX: This needs some form of option-setting
|
216
|
+
result1, _s = Open3.capture2("ditaa #{file.path} --svg -o -", stdin_data: result);
|
217
|
+
result1 = svg_clean(result1)
|
218
|
+
when "mscgen"
|
219
|
+
result1, _s = Open3.capture2("mscgen -T svg -i #{file.path} -o -", stdin_data: result);
|
220
|
+
result1 = svg_clean(result1)
|
221
|
+
end
|
203
222
|
# warn ["goat:", result1.inspect]
|
204
223
|
file.unlink
|
205
224
|
result1, _s = Open3.capture2("svgcheck -qa", stdin_data: result1);
|
@@ -477,7 +496,8 @@ module Kramdown
|
|
477
496
|
end
|
478
497
|
end
|
479
498
|
end
|
480
|
-
rescue OpenURI::HTTPError,
|
499
|
+
rescue OpenURI::HTTPError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
500
|
+
SocketError, Timeout::Error => e
|
481
501
|
warn "*** #{e} while fetching #{url}"
|
482
502
|
end
|
483
503
|
end
|
@@ -485,7 +505,7 @@ module Kramdown
|
|
485
505
|
begin
|
486
506
|
File.read(fn) # this blows up if no cache available after fetch attempt
|
487
507
|
rescue Errno::ENOENT => e
|
488
|
-
warn "*** #{e} for
|
508
|
+
warn "*** #{e} for #{fn}"
|
489
509
|
end
|
490
510
|
end
|
491
511
|
|
@@ -537,7 +557,7 @@ module Kramdown
|
|
537
557
|
fn = "reference.#{t}.#{n}.xml"
|
538
558
|
sub, ttl, can_anchor = XML_RESOURCE_ORG_MAP[t]
|
539
559
|
ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
|
540
|
-
puts "Huh:
|
560
|
+
puts "*** Huh: #{fn}" unless sub
|
541
561
|
url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
|
542
562
|
if can_anchor # create anchor server-side for stand_alone: false
|
543
563
|
url << "?anchor=#{anchor}"
|
@@ -547,7 +567,10 @@ module Kramdown
|
|
547
567
|
to_insert.scrub! rescue nil # only do this for Ruby >= 2.1
|
548
568
|
# this may be a bit controversial: Don't break the build if reference is broken
|
549
569
|
if KRAMDOWN_OFFLINE
|
550
|
-
to_insert
|
570
|
+
unless to_insert
|
571
|
+
to_insert = "<reference anchor='#{anchor}'> <front> <title>*** BROKEN REFERENCE ***</title> <author> <organization/> </author> <date/> </front> </reference>"
|
572
|
+
warn "*** KRAMDOWN_OFFLINE: Inserting broken reference for #{fn}"
|
573
|
+
end
|
551
574
|
else
|
552
575
|
exit 66 unless to_insert # EX_NOINPUT
|
553
576
|
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.7
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|