kramdown-rfc2629 1.4.10 → 1.4.14
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-rfc2629 +86 -60
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +33 -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: 92062f28c5c76b9a5492c88c4f55fc2a426a25b44d344ea4a98f035d67de2c26
|
4
|
+
data.tar.gz: e17d3fce5cd6fe0bf2dd0364336b49b8de92de6e85bfbb09a90d365ae2605989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84185943775453981c67205b8364c7d3179612633cd31e86bd61c680bc95a7c12f6380fefd19068659e36d2a1ee51b5e2be659dc7ca1f09b514793075d22bf5a
|
7
|
+
data.tar.gz: bb345c9bde88d532d938efa61edf2163463b573197288a2c4e32e81e3ee4c5318b50ddf3bb5f077deb08cad61d0b16ccc65062af082e2a4d644fc444dedffd03
|
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
@@ -14,21 +14,29 @@ Encoding.default_external = "UTF-8" # wake up, smell the coffee
|
|
14
14
|
|
15
15
|
def boilerplate(key)
|
16
16
|
case key.downcase
|
17
|
-
when /\Abcp14(\+)?(-tagged)?\z/i
|
18
|
-
ret =
|
17
|
+
when /\Abcp14(info)?(\+)?(-tagged)?\z/i
|
18
|
+
ret = ''
|
19
|
+
if $1
|
20
|
+
ret << <<RFC8174ise
|
21
|
+
Although this document is not an IETF Standards Track publication, it
|
22
|
+
adopts the conventions for normative language to provide clarity of
|
23
|
+
instructions to the implementer.
|
24
|
+
RFC8174ise
|
25
|
+
end
|
26
|
+
ret << <<RFC8174
|
19
27
|
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
|
20
28
|
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
|
21
29
|
"MAY", and "OPTIONAL" in this document are to be interpreted as
|
22
30
|
described in BCP 14 {{!RFC2119}} {{!RFC8174}} when, and only when, they
|
23
31
|
appear in all capitals, as shown here.
|
24
32
|
RFC8174
|
25
|
-
if $
|
33
|
+
if $2
|
26
34
|
ret << <<PLUS
|
27
35
|
These words may also appear in this document in
|
28
36
|
lower case as plain English words, absent their normative meanings.
|
29
37
|
PLUS
|
30
38
|
end
|
31
|
-
if $
|
39
|
+
if $3
|
32
40
|
if $options.v3
|
33
41
|
ret << <<TAGGED
|
34
42
|
|
@@ -83,10 +91,68 @@ NORMINFORM = { "!" => :normative, "?" => :informative }
|
|
83
91
|
|
84
92
|
def yaml_load(input, *args)
|
85
93
|
if YAML.respond_to?(:safe_load)
|
86
|
-
|
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
|
87
99
|
else
|
88
100
|
YAML.load(input)
|
89
|
-
|
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
|
90
156
|
end
|
91
157
|
|
92
158
|
XREF_SECTIONS_RE = ::Kramdown::Parser::RFC2629Kramdown::SECTIONS_RE
|
@@ -115,10 +181,15 @@ def xml_from_sections(input)
|
|
115
181
|
# We put back the "---" plus gratuitous blank lines to hack the line number in errors
|
116
182
|
yaml_in = input[/---\s*/] << sections.shift[2]
|
117
183
|
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
|
184
|
+
|
118
185
|
coding_override = ps.has(:coding)
|
119
186
|
smart_quotes = ps[:smart_quotes]
|
120
187
|
typographic_symbols = ps[:typographic_symbols]
|
121
|
-
|
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)
|
122
193
|
|
123
194
|
# all the other sections are put in a Hash, possibly concatenated from parts there
|
124
195
|
sechash = Hash.new{ |h,k| h[k] = ""}
|
@@ -231,13 +302,12 @@ def xml_from_sections(input)
|
|
231
302
|
end
|
232
303
|
|
233
304
|
stand_alone = ps[:stand_alone]
|
234
|
-
link_defs = {}
|
235
305
|
|
236
306
|
[:normative, :informative].each do |sn|
|
237
307
|
if refs = ps[sn]
|
238
308
|
refs.each do |k, v|
|
239
309
|
href = k.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
|
240
|
-
link_defs[k] = ["##{href}", nil]
|
310
|
+
kramdown_options[:link_defs][k] = ["##{href}", nil] # allow [RFC2119] in addition to {{RFC2119}}
|
241
311
|
|
242
312
|
bibref = anchor_to_bibref[k] || k
|
243
313
|
bts, url = bibtagsys(bibref, k, stand_alone)
|
@@ -258,9 +328,7 @@ def xml_from_sections(input)
|
|
258
328
|
if bts && !v.delete("override")
|
259
329
|
warn "*** warning: explicit settings completely override canned bibxml in reference #{k}"
|
260
330
|
end
|
261
|
-
|
262
|
-
$global_markdown_options = options # For recursive calls in bibref annotation processing.
|
263
|
-
sechash[sn.to_s] << KramdownRFC::ref_to_xml(k, v)
|
331
|
+
sechash[sn.to_s] << KramdownRFC::ref_to_xml(href, v)
|
264
332
|
end
|
265
333
|
end
|
266
334
|
end
|
@@ -277,7 +345,7 @@ def xml_from_sections(input)
|
|
277
345
|
warn "*** sections left #{sechash.keys.inspect}!"
|
278
346
|
end
|
279
347
|
|
280
|
-
[input,
|
348
|
+
[input, kramdown_options, coding_override]
|
281
349
|
end
|
282
350
|
|
283
351
|
XML_RESOURCE_ORG_PREFIX = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_PREFIX
|
@@ -359,7 +427,6 @@ if $options.verbose && $options.v3
|
|
359
427
|
warn "*** not much RFCXMLv3 stuff implemented yet"
|
360
428
|
end
|
361
429
|
|
362
|
-
coding_override = :as_char
|
363
430
|
input = ARGF.read
|
364
431
|
if input[0] == "\uFEFF"
|
365
432
|
warn "*** There is a leading byte order mark. Ignored."
|
@@ -380,59 +447,18 @@ if input =~ /[\t]/
|
|
380
447
|
input = expand_tabs(input)
|
381
448
|
end
|
382
449
|
|
383
|
-
link_defs = {}
|
384
450
|
if input =~ /\A---/ # this is a sectionized file
|
385
451
|
do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
|
386
|
-
input,
|
452
|
+
input, options, coding_override = xml_from_sections(input)
|
453
|
+
else
|
454
|
+
options = process_kramdown_options # all default
|
387
455
|
end
|
388
456
|
if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
|
389
457
|
input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
|
390
458
|
end
|
391
|
-
options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
|
392
|
-
if smart_quotes.nil?
|
393
|
-
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
394
|
-
smart_quotes = false
|
395
|
-
end
|
396
|
-
end
|
397
|
-
if smart_quotes == false
|
398
|
-
smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
|
399
|
-
end
|
400
|
-
case smart_quotes
|
401
|
-
when Array
|
402
|
-
options[:smart_quotes] = smart_quotes
|
403
|
-
when nil, true
|
404
|
-
# nothin
|
405
|
-
else
|
406
|
-
warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
|
407
|
-
end
|
408
|
-
if typographic_symbols.nil?
|
409
|
-
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
410
|
-
typographic_symbols = false
|
411
|
-
end
|
412
|
-
end
|
413
|
-
if typographic_symbols == false
|
414
|
-
typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
|
415
|
-
if Symbol === v
|
416
|
-
[v.intern, k]
|
417
|
-
end
|
418
|
-
}.compact]
|
419
|
-
end
|
420
|
-
# warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
|
421
|
-
case typographic_symbols
|
422
|
-
when Hash
|
423
|
-
options[:typographic_symbols] = typographic_symbols
|
424
|
-
when nil, true
|
425
|
-
# nothin
|
426
|
-
else
|
427
|
-
warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
|
428
|
-
end
|
429
|
-
|
430
|
-
if kramdown_options
|
431
|
-
options.merge! kramdown_options
|
432
|
-
end
|
433
459
|
|
434
|
-
if
|
435
|
-
input = input.encode(Encoding.find(
|
460
|
+
if coding_override
|
461
|
+
input = input.encode(Encoding.find(coding_override), fallback: FALLBACK)
|
436
462
|
end
|
437
463
|
|
438
464
|
# warn "options: #{options.inspect}"
|
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.14'
|
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
@@ -363,6 +363,19 @@ COLORS
|
|
363
363
|
end
|
364
364
|
end
|
365
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
|
+
|
366
379
|
def svg_clean(s) # expensive, risky
|
367
380
|
d = REXML::Document.new(s)
|
368
381
|
REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil } #; warn x.inspect }
|
@@ -407,9 +420,12 @@ COLORS
|
|
407
420
|
file = Tempfile.new("kramdown-rfc")
|
408
421
|
file.write(result)
|
409
422
|
file.close
|
423
|
+
dont_clean = false
|
424
|
+
dont_check = false
|
410
425
|
case t
|
411
426
|
when "goat"
|
412
427
|
result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
|
428
|
+
dont_clean = true
|
413
429
|
when "ditaa" # XXX: This needs some form of option-setting
|
414
430
|
result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -", stdin_data: result);
|
415
431
|
when "mscgen"
|
@@ -424,18 +440,27 @@ COLORS
|
|
424
440
|
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
|
425
441
|
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
426
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
|
427
449
|
when "math"
|
428
450
|
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
|
429
451
|
result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
|
430
452
|
err << err1
|
431
453
|
end
|
432
454
|
capture_croak(t, err)
|
433
|
-
# warn ["
|
455
|
+
# warn ["text:", result.inspect]
|
456
|
+
# warn ["svg:", result1.inspect]
|
434
457
|
file.unlink
|
435
|
-
result1 = svg_clean(result1) unless
|
436
|
-
|
437
|
-
|
438
|
-
|
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
|
439
464
|
if result1 == ''
|
440
465
|
warn "*** could not create svg for #{result.inspect[0...20]}..."
|
441
466
|
exit 65 # EX_DATAERR
|
@@ -490,7 +515,8 @@ COLORS
|
|
490
515
|
end
|
491
516
|
end
|
492
517
|
case t
|
493
|
-
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",
|
518
|
+
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",
|
519
|
+
"railroad", "railroad-utf8", "mermaid", "math"
|
494
520
|
if gi
|
495
521
|
warn "*** Can't set GI #{gi} for composite SVG artset"
|
496
522
|
end
|
@@ -891,6 +917,7 @@ COLORS
|
|
891
917
|
],
|
892
918
|
"W3C" => "bibxml4",
|
893
919
|
"3GPP" => "bibxml5",
|
920
|
+
"SDO-3GPP" => "bibxml5",
|
894
921
|
"ANSI" => "bibxml2",
|
895
922
|
"CCITT" => "bibxml2",
|
896
923
|
"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.14
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|