kramdown-rfc2629 1.4.6 → 1.4.11
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/kramdown-rfc-cache-subseries-bibxml +120 -0
- data/bin/kramdown-rfc2629 +29 -6
- data/data/kramdown-rfc2629.erb +1 -1
- data/kramdown-rfc2629.gemspec +3 -2
- data/lib/kramdown-rfc/parameterset.rb +6 -7
- data/lib/kramdown-rfc2629.rb +109 -35
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 550eb712315978bfe6985b74bce8ed0c2c8d69c94ecd0e78e3950d8822644aed
|
4
|
+
data.tar.gz: 5b51583ad31b2c00d9e490e983b6465a51fb84a334fff1ea42e24212f0d24968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9033a5b37fa0fdc30bce1c4d02d987d96f895dfad5b3adb6419bd5bad4c5fbd0074edcaa0de955fc1857764d159df8f54b4a7bd4ef4720c3f9b0edc3645ebdd4
|
7
|
+
data.tar.gz: ee00920f4806f49f74d36343218453f8e886fd93f12949b37dbc92fabeab6947237065f997fa13218ded3b492a5d7a4c40901d9707f7973d28b8318f4dfcbcca
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# prerequisite:
|
3
|
+
# gem install net-http-persistent
|
4
|
+
#
|
5
|
+
# generates referencegroup files for BCP and STD series (like bibxml9)
|
6
|
+
# unfortunately, needs to re-fetch rfc-index.xml
|
7
|
+
# uses pretty slow built-in XML parser, so it will take a while even on regen
|
8
|
+
#
|
9
|
+
# uses ENV["KRAMDOWN_REFCACHEDIR"] for where you want to have your bibxml9 data
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'rexml/document'
|
13
|
+
require 'fileutils'
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'net/http/persistent'
|
17
|
+
rescue
|
18
|
+
warn "*** please install net-http-persistent:"
|
19
|
+
warn " gem install net-http-persistent"
|
20
|
+
warn "(prefix by sudo only if required)."
|
21
|
+
exit 72 # EX_OSFILE
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
TARGET_DIR = ENV["KRAMDOWN_REFCACHEDIR"] || (
|
26
|
+
path = File.expand_path("~/.cache/xml2rfc")
|
27
|
+
warn "*** set environment variable KRAMDOWN_REFCACHEDIR to #{path} to actually use the cache"
|
28
|
+
path
|
29
|
+
)
|
30
|
+
|
31
|
+
FileUtils.mkdir_p(TARGET_DIR)
|
32
|
+
FileUtils.chdir(TARGET_DIR)
|
33
|
+
|
34
|
+
$http = Net::HTTP::Persistent.new name: 'subseries'
|
35
|
+
|
36
|
+
KRAMDOWN_PERSISTENT_VERBOSE = true
|
37
|
+
|
38
|
+
def get_and_write_resource_persistently(url, fn, age_verbose=false)
|
39
|
+
t1 = Time.now
|
40
|
+
response = $http.request(URI(url))
|
41
|
+
if response.code != "200"
|
42
|
+
raise "*** Status code #{response.code} while fetching #{url}"
|
43
|
+
else
|
44
|
+
File.write(fn, response.body)
|
45
|
+
end
|
46
|
+
t2 = Time.now
|
47
|
+
warn "#{url} -> #{fn} (#{"%.3f" % (t2 - t1)} s)" if KRAMDOWN_PERSISTENT_VERBOSE
|
48
|
+
if age_verbose
|
49
|
+
if age = response.get_fields("age")
|
50
|
+
warn "(working from a web cache, index is #{age.first} seconds stale)"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
CLEAR_RET = "\e[K\r" # XXX all the world is ECMA-48 (ISO 6429), no?
|
56
|
+
|
57
|
+
def noisy(name)
|
58
|
+
print "#{name}...#{CLEAR_RET}"
|
59
|
+
end
|
60
|
+
def clear_noise
|
61
|
+
print CLEAR_RET
|
62
|
+
end
|
63
|
+
|
64
|
+
def normalize_name(n)
|
65
|
+
n.sub(/([A-Z])0+/) {$1}
|
66
|
+
end
|
67
|
+
|
68
|
+
def regress_name(n)
|
69
|
+
n.sub(/([A-Z])(\d+)/) {"#$1#{"%04d" % $2.to_i}"}
|
70
|
+
end
|
71
|
+
|
72
|
+
def regress_name_dot(n)
|
73
|
+
n.sub(/([A-Z])(\d+)/) {"#$1.#{"%04d" % $2.to_i}"}
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_ref(rfcname)
|
77
|
+
name = "reference.#{regress_name_dot(rfcname)}.xml"
|
78
|
+
begin
|
79
|
+
file = File.read(name) # no age check
|
80
|
+
rescue Errno::ENOENT
|
81
|
+
get_and_write_resource_persistently("https://www.rfc-editor.org/refs/bibxml/" << name, name)
|
82
|
+
file = File.read(name)
|
83
|
+
end
|
84
|
+
d = REXML::Document.new(file)
|
85
|
+
d.xml_decl.nowrite
|
86
|
+
"<!-- #{name} -->\n" << d.to_s.lstrip
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_bib(series, subname, rfcnames)
|
90
|
+
p [series, subname, rfcnames]
|
91
|
+
subname_norm = normalize_name(subname)
|
92
|
+
refs = %{<?xml version='1.0' encoding='UTF-8'?>\n}
|
93
|
+
refs << %{<referencegroup anchor='#{subname_norm}' target='https://www.rfc-editor.org/info/#{subname_norm.downcase}'>\n}
|
94
|
+
refs << rfcnames.map {|x| get_ref(x)}.join
|
95
|
+
refs << "</referencegroup>\n"
|
96
|
+
File.write("reference.#{regress_name_dot(subname)}.xml", refs)
|
97
|
+
end
|
98
|
+
|
99
|
+
def handle_sub(series, entry)
|
100
|
+
ids = entry.get_elements("doc-id")
|
101
|
+
warn "** ids #{ids} #{entry}" unless ids.size == 1
|
102
|
+
subname = ids.first.text
|
103
|
+
isalso = entry.get_elements("is-also")
|
104
|
+
if isalso.size == 1
|
105
|
+
rfcs = isalso.first.get_elements("doc-id")
|
106
|
+
if rfcs.size > 0
|
107
|
+
rfcnames = rfcs.map {|r| r.text}
|
108
|
+
create_bib(series, subname, rfcnames)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
RFCINDEX_SOURCE = "https://www.rfc-editor.org/rfc/rfc-index.xml"
|
114
|
+
RFCINDEX_COPY = File.basename(RFCINDEX_SOURCE)
|
115
|
+
|
116
|
+
get_and_write_resource_persistently(RFCINDEX_SOURCE, RFCINDEX_COPY, true) unless ENV["KRAMDOWN_DONT_REFRESH_RFCINDEX"]
|
117
|
+
|
118
|
+
doc = REXML::Document.new(File.read(RFCINDEX_COPY))
|
119
|
+
REXML::XPath.each(doc.root, "/rfc-index/bcp-entry") { |e| handle_sub("BCP", e) }
|
120
|
+
REXML::XPath.each(doc.root, "/rfc-index/std-entry") { |e| handle_sub("STD", e) }
|
data/bin/kramdown-rfc2629
CHANGED
@@ -89,6 +89,16 @@ def yaml_load(input, *args)
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
XREF_SECTIONS_RE = ::Kramdown::Parser::RFC2629Kramdown::SECTIONS_RE
|
93
|
+
XSR_PREFIX = "#{XREF_SECTIONS_RE} of "
|
94
|
+
XSR_SUFFIX = ", (#{XREF_SECTIONS_RE})| \\((#{XREF_SECTIONS_RE})\\)"
|
95
|
+
XREF_TXT = ::Kramdown::Parser::RFC2629Kramdown::XREF_TXT
|
96
|
+
XREF_TXT_SUFFIX = " \\(#{XREF_TXT}\\)"
|
97
|
+
|
98
|
+
def spacify_re(s)
|
99
|
+
s.gsub(' ', '[\u00A0\s]+')
|
100
|
+
end
|
101
|
+
|
92
102
|
def xml_from_sections(input)
|
93
103
|
|
94
104
|
unless ENV["KRAMDOWN_NO_SOURCE"]
|
@@ -158,11 +168,20 @@ def xml_from_sections(input)
|
|
158
168
|
# collect normative/informative tagging {{!RFC2119}} {{?RFC4711}}
|
159
169
|
sechash.each do |k, v|
|
160
170
|
next if k == "fluff"
|
161
|
-
v.gsub!(/{{(
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
171
|
+
v.gsub!(/{{(#{
|
172
|
+
spacify_re(XSR_PREFIX)
|
173
|
+
})?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
|
174
|
+
XREF_TXT_SUFFIX
|
175
|
+
})?(#{
|
176
|
+
spacify_re(XSR_SUFFIX)
|
177
|
+
})?}}/) do |match|
|
178
|
+
xsr_prefix = $1
|
179
|
+
norminform = $2
|
180
|
+
replacing = $3 || $4
|
181
|
+
word = $5
|
182
|
+
bibref = $6
|
183
|
+
xrt_suffix = $7
|
184
|
+
xsr_suffix = $8
|
166
185
|
if replacing
|
167
186
|
if new = ref_replacements[word]
|
168
187
|
word = new
|
@@ -186,7 +205,7 @@ def xml_from_sections(input)
|
|
186
205
|
if norminform
|
187
206
|
norm_ref[word] ||= norminform == '!' # one normative ref is enough
|
188
207
|
end
|
189
|
-
"{{#{word}}}"
|
208
|
+
"{{#{xsr_prefix}#{word}#{xrt_suffix}#{xsr_suffix}}}"
|
190
209
|
end
|
191
210
|
end
|
192
211
|
|
@@ -269,6 +288,10 @@ def bibtagsys(bib, anchor=nil, stand_alone=true)
|
|
269
288
|
rfc4d = "%04d" % $1.to_i
|
270
289
|
[bib.upcase,
|
271
290
|
"#{XML_RESOURCE_ORG_PREFIX}/bibxml/reference.RFC.#{rfc4d}.xml"]
|
291
|
+
elsif $options.v3 && bib =~ /\A(bcp|std)(\d+)/i
|
292
|
+
n4d = "%04d" % $2.to_i
|
293
|
+
[bib.upcase,
|
294
|
+
"#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries-new/reference.#{$1.upcase}.#{n4d}.xml"]
|
272
295
|
elsif bib =~ /\A([-A-Z0-9]+)\./ &&
|
273
296
|
(xro = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_MAP[$1])
|
274
297
|
dir, _ttl, rewrite_anchor = xro
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
<name>Contributors</name>
|
101
101
|
<% else -%>
|
102
102
|
<section anchor="contributors" numbered="false" title="Contributors">
|
103
|
-
<% warn "***
|
103
|
+
<% warn "*** To use YAML contributors, use --v3 (kdrfc -3)" if consec -%>
|
104
104
|
<% end -%>
|
105
105
|
<%= sh -%>
|
106
106
|
<% if $options.v3 && consec
|
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.4.
|
3
|
+
s.version = '1.4.11'
|
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.}
|
@@ -10,7 +10,8 @@ spec = Gem::Specification.new do |s|
|
|
10
10
|
s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json)
|
11
11
|
s.require_path = 'lib'
|
12
12
|
s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
|
13
|
-
'kdrfc', 'kramdown-rfc-cache-i-d-bibxml'
|
13
|
+
'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
|
14
|
+
'kramdown-rfc-cache-subseries-bibxml']
|
14
15
|
s.required_ruby_version = '>= 2.3.0'
|
15
16
|
# s.requirements = 'wget'
|
16
17
|
# s.has_rdoc = true
|
@@ -34,13 +34,12 @@ module KramdownRFC
|
|
34
34
|
val ||= defcontent
|
35
35
|
Array(val).map do |val1|
|
36
36
|
v = val1.to_s.strip
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
37
|
+
contents =
|
38
|
+
if markdown
|
39
|
+
::Kramdown::Converter::Rfc2629::process_markdown(v)
|
40
|
+
else
|
41
|
+
escape_html(v)
|
42
|
+
end
|
44
43
|
%{<#{[an, *Array(attr).map(&:to_s)].join(" ").strip}>#{contents}</#{an}>}
|
45
44
|
end.join(" ")
|
46
45
|
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -42,32 +42,50 @@ module Kramdown
|
|
42
42
|
@block_parsers.unshift(:block_pi)
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
45
|
+
XREF_BASE = /[\w.-]+/ # a token for a reference
|
46
|
+
XREF_TXT = /(?:[^\(]|\([^\)]*\))+/ # parenthesized text
|
47
|
+
XREF_RE = /#{XREF_BASE}(?: \(#{XREF_TXT}\))?/
|
48
|
+
XREF_RE_M = /\A(#{XREF_BASE})(?: \((#{XREF_TXT})\))?/ # matching version of XREF_RE
|
49
|
+
XREF_SINGLE = /(?:Section|Appendix) #{XREF_RE}/
|
50
|
+
XREF_MULTI = /(?:Sections|Appendices) (?:#{XREF_RE}, )*#{XREF_RE},? and #{XREF_RE}/
|
51
|
+
XREF_ANY = /(?:#{XREF_SINGLE}|#{XREF_MULTI})/
|
52
|
+
SECTIONS_RE = /(?:#{XREF_ANY} and )?#{XREF_ANY}/
|
53
|
+
|
54
|
+
def handle_bares(s, attr, format, href, last_join = nil)
|
55
|
+
if s.match(/\A(#{XREF_ANY}) and (#{XREF_ANY})\z/)
|
56
|
+
handle_bares($1, {}, nil, href, " and ")
|
57
|
+
handle_bares($2, {}, nil, href, " of ")
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
href = href.split(' ')[0] # Remove any trailing (...)
|
62
|
+
multi = last_join != nil
|
63
|
+
(sn, s) = s.split(' ', 2)
|
64
|
+
loop do
|
65
|
+
m = s.match(/\A#{XREF_RE_M}(, (?:and )?| and )?/)
|
66
|
+
break if not m
|
67
|
+
|
68
|
+
if not multi and not m[2] and not m[3]
|
69
|
+
# Modify |attr| if there is a single reference. This can only be
|
70
|
+
# used if there is only one section reference and the section part
|
71
|
+
# has no title.
|
72
|
+
attr['section'] = m[1]
|
73
|
+
attr['sectionFormat'] = format
|
74
|
+
attr['text'] = m[2]
|
75
|
+
return
|
66
76
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
|
78
|
+
if sn
|
79
|
+
@tree.children << Element.new(:text, "#{sn} ", {})
|
80
|
+
sn = nil
|
81
|
+
end
|
82
|
+
|
83
|
+
multi = true
|
84
|
+
s[m[0]] = ''
|
85
|
+
|
86
|
+
attr1 = { 'target' => href, 'section' => m[1], 'sectionFormat' => 'bare', 'text' => m[2] }
|
87
|
+
@tree.children << Element.new(:xref, nil, attr1)
|
88
|
+
@tree.children << Element.new(:text, m[3] || last_join || " of ", {})
|
71
89
|
end
|
72
90
|
end
|
73
91
|
|
@@ -114,6 +132,10 @@ module Kramdown
|
|
114
132
|
attr['format'] = 'counter'
|
115
133
|
end
|
116
134
|
end
|
135
|
+
if href.match(XREF_RE_M)
|
136
|
+
href = $1
|
137
|
+
attr['text'] = $2
|
138
|
+
end
|
117
139
|
href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
|
118
140
|
attr['target'] = href
|
119
141
|
el = Element.new(:xref, nil, attr)
|
@@ -288,6 +310,12 @@ module Kramdown
|
|
288
310
|
generate_id(value).gsub(/-+/, '-')
|
289
311
|
end
|
290
312
|
|
313
|
+
def self.process_markdown(v) # Uuh. Heavy coupling.
|
314
|
+
doc = ::Kramdown::Document.new(v, $global_markdown_options)
|
315
|
+
$stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
|
316
|
+
doc.to_rfc2629[3..-6] # skip <t>...</t>\n
|
317
|
+
end
|
318
|
+
|
291
319
|
SVG_COLORS = Hash.new {|h, k| k}
|
292
320
|
<<COLORS.each_line {|l| k, v = l.chomp.split; SVG_COLORS[k] = v}
|
293
321
|
black #000000
|
@@ -335,6 +363,19 @@ COLORS
|
|
335
363
|
end
|
336
364
|
end
|
337
365
|
|
366
|
+
def svg_clean_kgt(s)
|
367
|
+
d = REXML::Document.new(s)
|
368
|
+
REXML::XPath.each(d.root, "//rect|//line|//path") do |x|
|
369
|
+
x.attributes["fill"] = "none"
|
370
|
+
x.attributes["stroke"] = "black"
|
371
|
+
x.attributes["stroke-width"] = "1.5"
|
372
|
+
end
|
373
|
+
d.to_s
|
374
|
+
rescue => detail
|
375
|
+
warn "*** Can't clean SVG: #{detail}"
|
376
|
+
d
|
377
|
+
end
|
378
|
+
|
338
379
|
def svg_clean(s) # expensive, risky
|
339
380
|
d = REXML::Document.new(s)
|
340
381
|
REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil } #; warn x.inspect }
|
@@ -379,9 +420,12 @@ COLORS
|
|
379
420
|
file = Tempfile.new("kramdown-rfc")
|
380
421
|
file.write(result)
|
381
422
|
file.close
|
423
|
+
dont_clean = false
|
424
|
+
dont_check = false
|
382
425
|
case t
|
383
426
|
when "goat"
|
384
427
|
result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
|
428
|
+
dont_clean = true
|
385
429
|
when "ditaa" # XXX: This needs some form of option-setting
|
386
430
|
result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -", stdin_data: result);
|
387
431
|
when "mscgen"
|
@@ -396,18 +440,27 @@ COLORS
|
|
396
440
|
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
|
397
441
|
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
398
442
|
err << err1.to_s
|
443
|
+
when "railroad", "railroad-utf8"
|
444
|
+
result1, err1, _s = Open3.capture3("kgt -l abnf -e svg", stdin_data: result);
|
445
|
+
result1 = svg_clean_kgt(result1); dont_clean = true
|
446
|
+
result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}",
|
447
|
+
stdin_data: result);
|
448
|
+
err << err1.to_s
|
399
449
|
when "math"
|
400
450
|
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
|
401
451
|
result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
|
402
452
|
err << err1
|
403
453
|
end
|
404
454
|
capture_croak(t, err)
|
405
|
-
# warn ["
|
455
|
+
# warn ["text:", result.inspect]
|
456
|
+
# warn ["svg:", result1.inspect]
|
406
457
|
file.unlink
|
407
|
-
result1 = svg_clean(result1) unless
|
408
|
-
|
409
|
-
|
410
|
-
|
458
|
+
result1 = svg_clean(result1) unless dont_clean
|
459
|
+
unless dont_check
|
460
|
+
result1, err, _s = Open3.capture3("svgcheck -Xqa", stdin_data: result1);
|
461
|
+
# warn ["svgcheck:", result1.inspect]
|
462
|
+
capture_croak("svgcheck", err)
|
463
|
+
end
|
411
464
|
if result1 == ''
|
412
465
|
warn "*** could not create svg for #{result.inspect[0...20]}..."
|
413
466
|
exit 65 # EX_DATAERR
|
@@ -462,7 +515,8 @@ COLORS
|
|
462
515
|
end
|
463
516
|
end
|
464
517
|
case t
|
465
|
-
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",
|
518
|
+
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",
|
519
|
+
"railroad", "railroad-utf8", "mermaid", "math"
|
466
520
|
if gi
|
467
521
|
warn "*** Can't set GI #{gi} for composite SVG artset"
|
468
522
|
end
|
@@ -729,6 +783,7 @@ COLORS
|
|
729
783
|
|
730
784
|
def convert_xref(el, indent, opts)
|
731
785
|
gi = el.attr.delete('gi')
|
786
|
+
text = el.attr.delete('text')
|
732
787
|
target = el.attr['target']
|
733
788
|
if target[0] == "&"
|
734
789
|
"#{target};"
|
@@ -738,7 +793,12 @@ COLORS
|
|
738
793
|
else
|
739
794
|
gi ||= "xref"
|
740
795
|
end
|
741
|
-
|
796
|
+
if text
|
797
|
+
tail = ">#{Rfc2629::process_markdown(text)}</#{gi}>"
|
798
|
+
else
|
799
|
+
tail = "/>"
|
800
|
+
end
|
801
|
+
"<#{gi}#{el_html_attributes(el)}#{tail}"
|
742
802
|
end
|
743
803
|
end
|
744
804
|
|
@@ -833,13 +893,27 @@ COLORS
|
|
833
893
|
end
|
834
894
|
end
|
835
895
|
|
896
|
+
def self.bcp_std_ref(t, n)
|
897
|
+
warn "*** #{t} anchors not supported in v2 format" unless $options.v3
|
898
|
+
[name = "reference.#{t}.#{"%04d" % n.to_i}.xml",
|
899
|
+
"#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries-new/#{name}"] # FOR NOW
|
900
|
+
end
|
901
|
+
|
836
902
|
# [subdirectory name, cache ttl in seconds, does it provide for ?anchor=]
|
837
903
|
XML_RESOURCE_ORG_MAP = {
|
838
904
|
"RFC" => ["bibxml", 86400*7, false,
|
839
|
-
->(fn, n){ "
|
905
|
+
->(fn, n){ [name = "reference.RFC.#{"%04d" % n.to_i}.xml",
|
906
|
+
"https://www.rfc-editor.org/refs/bibxml/#{name}"] }
|
840
907
|
],
|
841
908
|
"I-D" => ["bibxml3", false, false,
|
842
|
-
->(fn, n){
|
909
|
+
->(fn, n){ [fn,
|
910
|
+
"https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}/xml"] }
|
911
|
+
],
|
912
|
+
"BCP" => ["bibxml-rfcsubseries", 86400*7, false,
|
913
|
+
->(fn, n){ Rfc2629::bcp_std_ref("BCP", n) }
|
914
|
+
],
|
915
|
+
"STD" => ["bibxml-rfcsubseries", 86400*7, false,
|
916
|
+
->(fn, n){ Rfc2629::bcp_std_ref("STD", n) }
|
843
917
|
],
|
844
918
|
"W3C" => "bibxml4",
|
845
919
|
"3GPP" => "bibxml5",
|
@@ -890,7 +964,7 @@ COLORS
|
|
890
964
|
ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
|
891
965
|
puts "*** Huh: #{fn}" unless sub
|
892
966
|
if altproc && !KRAMDOWN_USE_TOOLS_SERVER
|
893
|
-
url = altproc.call(fn, n)
|
967
|
+
fn, url = altproc.call(fn, n)
|
894
968
|
else
|
895
969
|
url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
|
896
970
|
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.4.
|
4
|
+
version: 1.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -62,6 +62,7 @@ executables:
|
|
62
62
|
- kramdown-rfc-extract-markdown
|
63
63
|
- kdrfc
|
64
64
|
- kramdown-rfc-cache-i-d-bibxml
|
65
|
+
- kramdown-rfc-cache-subseries-bibxml
|
65
66
|
extensions: []
|
66
67
|
extra_rdoc_files: []
|
67
68
|
files:
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- bin/doilit
|
71
72
|
- bin/kdrfc
|
72
73
|
- bin/kramdown-rfc-cache-i-d-bibxml
|
74
|
+
- bin/kramdown-rfc-cache-subseries-bibxml
|
73
75
|
- bin/kramdown-rfc-extract-markdown
|
74
76
|
- bin/kramdown-rfc2629
|
75
77
|
- data/encoding-fallbacks.txt
|