kramdown-rfc2629 1.4.11 → 1.4.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 550eb712315978bfe6985b74bce8ed0c2c8d69c94ecd0e78e3950d8822644aed
4
- data.tar.gz: 5b51583ad31b2c00d9e490e983b6465a51fb84a334fff1ea42e24212f0d24968
3
+ metadata.gz: 3ec3a8a34552f96ed3950ba50d5473659fb48beeb11235828390613734647be4
4
+ data.tar.gz: 77c1681732519cffe53f44f2039b8d5fd3ffa93fc68bfa508546089ecc98e53d
5
5
  SHA512:
6
- metadata.gz: 9033a5b37fa0fdc30bce1c4d02d987d96f895dfad5b3adb6419bd5bad4c5fbd0074edcaa0de955fc1857764d159df8f54b4a7bd4ef4720c3f9b0edc3645ebdd4
7
- data.tar.gz: ee00920f4806f49f74d36343218453f8e886fd93f12949b37dbc92fabeab6947237065f997fa13218ded3b492a5d7a4c40901d9707f7973d28b8318f4dfcbcca
6
+ metadata.gz: ca15e2ae0b6e0136e7e337dd51829534e0f668cd10c2997a017c4d38181c3fbb2f5f8d180f48b31523f5a4a3947ab8224f189e3e6d48b61aade39f8ba4aff858
7
+ data.tar.gz: 8ebd377def30fe512a0a715d3690049b56e0eb4ea12cd16fadd449132519acee841e8f57bd9e152ef528355f983c4635cb8b141e9cc7cb3472601acd24633e86
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 = <<RFC8174
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 $1
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 $2
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
- YAML.safe_load(input, *args)
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
- end
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
- kramdown_options = ps[:kramdown_options]
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] # allow [RFC2119] in addition to {{RFC2119}}
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
- options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
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, coding_override, link_defs, smart_quotes, typographic_symbols, kramdown_options]
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, target_coding, link_defs, smart_quotes, typographic_symbols, kramdown_options = xml_from_sections(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 target_coding
435
- input = input.encode(Encoding.find(target_coding), fallback: FALLBACK)
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}"
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.4.11'
3
+ s.version = '1.4.15'
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.}
@@ -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 "** Can't set up persistent HTTP -- #{e}"
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.11
4
+ version: 1.4.15
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-05-08 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown