kramdown-rfc2629 1.4.12 → 1.4.17
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 +1 -1
- data/bin/kramdown-rfc-cache-i-d-bibxml +1 -1
- data/bin/kramdown-rfc2629 +85 -56
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +5 -1
- 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: 995b589ce86783d0aa3f5e3193cdb0399ace572b239fade7995c5699f6e4f8de
|
4
|
+
data.tar.gz: ea44d32db3e9c9a57210da431859ede63d5a2d756dd05f0beee9bbc1722e2cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e51f7d06bc29eb1cef1c475443f207474e23e903e0b9880ec29507a902aba034407821dbfa177aca297905571a6f404e651eefb62005bea55715fed885dd575
|
7
|
+
data.tar.gz: fccef7a2f854bebea02100f3dea2ab5c5cbcd0800f2bcd83272869d40255d1455aa76ecc5137e78c22f4871b4971acbbc02a00b7656a12cd595ebe1444447fb7
|
data/bin/kdrfc
CHANGED
@@ -127,7 +127,7 @@ BANNER
|
|
127
127
|
opts.on("-p", "--[no-]prep", "Convert xml to prepped xml") do |v|
|
128
128
|
$options.prep = v
|
129
129
|
end
|
130
|
-
opts.on("-P", "--[no-]pdf", "Convert xml to PDF") do |v|
|
130
|
+
opts.on("-P", "-f", "--[no-]pdf", "Convert xml to PDF") do |v|
|
131
131
|
$options.pdf = v
|
132
132
|
end
|
133
133
|
opts.on("-c", "--[no-]convert", "Convert xml to v3 xml") do |v|
|
data/bin/kramdown-rfc2629
CHANGED
@@ -18,7 +18,7 @@ def boilerplate(key)
|
|
18
18
|
ret = ''
|
19
19
|
if $1
|
20
20
|
ret << <<RFC8174ise
|
21
|
-
Although this document is not an IETF Standards Track publication it
|
21
|
+
Although this document is not an IETF Standards Track publication, it
|
22
22
|
adopts the conventions for normative language to provide clarity of
|
23
23
|
instructions to the implementer.
|
24
24
|
RFC8174ise
|
@@ -91,10 +91,68 @@ NORMINFORM = { "!" => :normative, "?" => :informative }
|
|
91
91
|
|
92
92
|
def yaml_load(input, *args)
|
93
93
|
if YAML.respond_to?(:safe_load)
|
94
|
-
|
94
|
+
begin
|
95
|
+
YAML.safe_load(input, *args)
|
96
|
+
rescue ArgumentError
|
97
|
+
YAML.safe_load(input, permitted_classes: args[0], permitted_symbols: args[1], aliases: args[2])
|
98
|
+
end
|
95
99
|
else
|
96
100
|
YAML.load(input)
|
97
|
-
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def process_kramdown_options(coding_override = nil,
|
105
|
+
smart_quotes = nil, typographic_symbols = nil,
|
106
|
+
header_kramdown_options = nil)
|
107
|
+
|
108
|
+
ascii_target = coding_override && coding_override =~ /ascii/
|
109
|
+
suppress_typography = ascii_target || $options.v3
|
110
|
+
entity_output = ascii_target ? :numeric : :as_char;
|
111
|
+
|
112
|
+
options = {input: 'RFC2629Kramdown', entity_output: entity_output, link_defs: {}}
|
113
|
+
|
114
|
+
if smart_quotes.nil? && suppress_typography
|
115
|
+
smart_quotes = false
|
116
|
+
end
|
117
|
+
if smart_quotes == false
|
118
|
+
smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
|
119
|
+
end
|
120
|
+
case smart_quotes
|
121
|
+
when Array
|
122
|
+
options[:smart_quotes] = smart_quotes
|
123
|
+
when nil, true
|
124
|
+
# nothin
|
125
|
+
else
|
126
|
+
warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
|
127
|
+
end
|
128
|
+
|
129
|
+
if typographic_symbols.nil? && suppress_typography
|
130
|
+
typographic_symbols = false
|
131
|
+
end
|
132
|
+
if typographic_symbols == false
|
133
|
+
typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
|
134
|
+
if Symbol === v
|
135
|
+
[v.intern, k]
|
136
|
+
end
|
137
|
+
}.compact]
|
138
|
+
end
|
139
|
+
# warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
|
140
|
+
case typographic_symbols
|
141
|
+
when Hash
|
142
|
+
options[:typographic_symbols] = typographic_symbols
|
143
|
+
when nil, true
|
144
|
+
# nothin
|
145
|
+
else
|
146
|
+
warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
|
147
|
+
end
|
148
|
+
|
149
|
+
if header_kramdown_options
|
150
|
+
options.merge! header_kramdown_options
|
151
|
+
end
|
152
|
+
|
153
|
+
$global_markdown_options = options # For nested calls in bibref annotation processing and xref text
|
154
|
+
|
155
|
+
options
|
98
156
|
end
|
99
157
|
|
100
158
|
XREF_SECTIONS_RE = ::Kramdown::Parser::RFC2629Kramdown::SECTIONS_RE
|
@@ -123,10 +181,15 @@ def xml_from_sections(input)
|
|
123
181
|
# We put back the "---" plus gratuitous blank lines to hack the line number in errors
|
124
182
|
yaml_in = input[/---\s*/] << sections.shift[2]
|
125
183
|
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
|
184
|
+
|
126
185
|
coding_override = ps.has(:coding)
|
127
186
|
smart_quotes = ps[:smart_quotes]
|
128
187
|
typographic_symbols = ps[:typographic_symbols]
|
129
|
-
|
188
|
+
header_kramdown_options = ps[:kramdown_options]
|
189
|
+
|
190
|
+
kramdown_options = process_kramdown_options(coding_override,
|
191
|
+
smart_quotes, typographic_symbols,
|
192
|
+
header_kramdown_options)
|
130
193
|
|
131
194
|
# all the other sections are put in a Hash, possibly concatenated from parts there
|
132
195
|
sechash = Hash.new{ |h,k| h[k] = ""}
|
@@ -239,13 +302,12 @@ def xml_from_sections(input)
|
|
239
302
|
end
|
240
303
|
|
241
304
|
stand_alone = ps[:stand_alone]
|
242
|
-
link_defs = {}
|
243
305
|
|
244
306
|
[:normative, :informative].each do |sn|
|
245
307
|
if refs = ps[sn]
|
246
308
|
refs.each do |k, v|
|
247
309
|
href = k.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
|
248
|
-
link_defs[k] = ["##{href}", nil]
|
310
|
+
kramdown_options[:link_defs][k] = ["##{href}", nil] # allow [RFC2119] in addition to {{RFC2119}}
|
249
311
|
|
250
312
|
bibref = anchor_to_bibref[k] || k
|
251
313
|
bts, url = bibtagsys(bibref, k, stand_alone)
|
@@ -266,9 +328,7 @@ def xml_from_sections(input)
|
|
266
328
|
if bts && !v.delete("override")
|
267
329
|
warn "*** warning: explicit settings completely override canned bibxml in reference #{k}"
|
268
330
|
end
|
269
|
-
|
270
|
-
$global_markdown_options = options # For recursive calls in bibref annotation processing.
|
271
|
-
sechash[sn.to_s] << KramdownRFC::ref_to_xml(k, v)
|
331
|
+
sechash[sn.to_s] << KramdownRFC::ref_to_xml(href, v)
|
272
332
|
end
|
273
333
|
end
|
274
334
|
end
|
@@ -285,7 +345,7 @@ def xml_from_sections(input)
|
|
285
345
|
warn "*** sections left #{sechash.keys.inspect}!"
|
286
346
|
end
|
287
347
|
|
288
|
-
[input,
|
348
|
+
[input, kramdown_options, coding_override]
|
289
349
|
end
|
290
350
|
|
291
351
|
XML_RESOURCE_ORG_PREFIX = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_PREFIX
|
@@ -367,7 +427,6 @@ if $options.verbose && $options.v3
|
|
367
427
|
warn "*** not much RFCXMLv3 stuff implemented yet"
|
368
428
|
end
|
369
429
|
|
370
|
-
coding_override = :as_char
|
371
430
|
input = ARGF.read
|
372
431
|
if input[0] == "\uFEFF"
|
373
432
|
warn "*** There is a leading byte order mark. Ignored."
|
@@ -388,62 +447,32 @@ if input =~ /[\t]/
|
|
388
447
|
input = expand_tabs(input)
|
389
448
|
end
|
390
449
|
|
391
|
-
link_defs = {}
|
392
450
|
if input =~ /\A---/ # this is a sectionized file
|
393
451
|
do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
|
394
|
-
input,
|
452
|
+
input, options, coding_override = xml_from_sections(input)
|
453
|
+
else
|
454
|
+
options = process_kramdown_options # all default
|
395
455
|
end
|
396
456
|
if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
|
397
457
|
input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
|
398
458
|
end
|
399
|
-
options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
|
400
|
-
if smart_quotes.nil?
|
401
|
-
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
402
|
-
smart_quotes = false
|
403
|
-
end
|
404
|
-
end
|
405
|
-
if smart_quotes == false
|
406
|
-
smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
|
407
|
-
end
|
408
|
-
case smart_quotes
|
409
|
-
when Array
|
410
|
-
options[:smart_quotes] = smart_quotes
|
411
|
-
when nil, true
|
412
|
-
# nothin
|
413
|
-
else
|
414
|
-
warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
|
415
|
-
end
|
416
|
-
if typographic_symbols.nil?
|
417
|
-
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
418
|
-
typographic_symbols = false
|
419
|
-
end
|
420
|
-
end
|
421
|
-
if typographic_symbols == false
|
422
|
-
typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
|
423
|
-
if Symbol === v
|
424
|
-
[v.intern, k]
|
425
|
-
end
|
426
|
-
}.compact]
|
427
|
-
end
|
428
|
-
# warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
|
429
|
-
case typographic_symbols
|
430
|
-
when Hash
|
431
|
-
options[:typographic_symbols] = typographic_symbols
|
432
|
-
when nil, true
|
433
|
-
# nothin
|
434
|
-
else
|
435
|
-
warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
|
436
|
-
end
|
437
459
|
|
438
|
-
if
|
439
|
-
|
460
|
+
if coding_override
|
461
|
+
input = input.encode(Encoding.find(coding_override), fallback: FALLBACK)
|
440
462
|
end
|
441
463
|
|
442
|
-
|
443
|
-
|
464
|
+
# 1.4.17: because of UTF-8 bibxml files, kramdown always needs to see UTF-8 (!)
|
465
|
+
if input.encoding != Encoding::UTF_8
|
466
|
+
input = input.encode(Encoding::UTF_8)
|
444
467
|
end
|
445
468
|
|
446
469
|
# warn "options: #{options.inspect}"
|
447
470
|
doc = Kramdown::Document.new(input, options)
|
448
471
|
$stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
|
449
|
-
|
472
|
+
output = doc.to_rfc2629
|
473
|
+
|
474
|
+
if coding_override
|
475
|
+
output = output.encode(Encoding.find(coding_override), fallback: FALLBACK)
|
476
|
+
end
|
477
|
+
|
478
|
+
puts output
|
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.17'
|
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
@@ -251,7 +251,10 @@ module Kramdown
|
|
251
251
|
require 'net/http/persistent'
|
252
252
|
$http = Net::HTTP::Persistent.new name: 'kramdown-rfc'
|
253
253
|
rescue Exception => e
|
254
|
-
warn "**
|
254
|
+
warn "** Not using persistent HTTP -- #{e}"
|
255
|
+
warn "** To silence this message and get full speed, try:"
|
256
|
+
warn "** gem install net-http-persistent"
|
257
|
+
warn "** If this doesn't work, you can ignore this warning."
|
255
258
|
end
|
256
259
|
end
|
257
260
|
|
@@ -917,6 +920,7 @@ COLORS
|
|
917
920
|
],
|
918
921
|
"W3C" => "bibxml4",
|
919
922
|
"3GPP" => "bibxml5",
|
923
|
+
"SDO-3GPP" => "bibxml5",
|
920
924
|
"ANSI" => "bibxml2",
|
921
925
|
"CCITT" => "bibxml2",
|
922
926
|
"FIPS" => "bibxml2",
|
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.17
|
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-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|