kramdown-rfc2629 1.5.22 → 1.6.1

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: 90fd02030501ff7ce234af8b2f2412b5c1372c8e865b368db995ab0a32347dc0
4
- data.tar.gz: 31d7f8eed4b7adc64e8ff4458368e1380351089aa44478faf2987a78239d5cae
3
+ metadata.gz: e14f146c7079e4611aa6ddf79f706ef0fddb168e1bb510c278ead6c93595b99a
4
+ data.tar.gz: efa3c83941f0eaa68e82d9d2bbe554826f70bee1469498e870506f006806bcf8
5
5
  SHA512:
6
- metadata.gz: a39fa3bf7a2703f958dbc443d1d8d850a0a89ec9797f619218e921cdadd372e4466f628a1a3dbf13f178163a16f92141026ac34bfd52c82f1950fd3780d187aa
7
- data.tar.gz: f02da291a9a611a4cb21097c2f31ee490a6327558cf1d66018279c89ef5f56f4ad87884046b19e44d347d5946346d0108a017e19aabb6b0db180f53a9847430a
6
+ metadata.gz: 54b21302c63267ecf9eaf845d67927c8f7f7dc78b4608c545fb6487274a507980695512d21397fa54c7700c3659600229c6dc0cab4964e2c8e9a471da9b51e00
7
+ data.tar.gz: '093aaa4efee63f5a103fba961072413884170bbcf13bb402b3ea40f36d1af1843d0b170be57d257dbf94f7b05bb6dc1e38df6a76abee06a5c475517fdd843d62'
data/README.md CHANGED
@@ -48,6 +48,19 @@ is provided by `kdrfc`:
48
48
 
49
49
  kdrfc -r mydraft.mkd
50
50
 
51
+ # Versions of RFCXML
52
+
53
+ Since RFC 8650, RFCs are using an updated grammar as defined in RFC
54
+ 7991 to 7998 and further updated informally since, colloquially called "[v3][]".
55
+ As RFC 2629 is no longer the governing standard, kramdown-rfc2629 is
56
+ now called kramdown-rfc. The latter command defaults to v3 processing
57
+ rules; from 2022-02-22T22:02:22 on, kramdown-rfc2629 does as well (1.6.1).
58
+ (-3/--v3 and -2/--v2 select v3 and v2 explicitly; the latter should
59
+ only be needed if there is a reason to to make a document look
60
+ like it's 2016.)
61
+
62
+ [v3]: https://xml2rfc.tools.ietf.org/xml2rfc-doc.html
63
+
51
64
  # Examples
52
65
 
53
66
  For historical interest
data/bin/kdrfc CHANGED
@@ -51,9 +51,26 @@ BANNER
51
51
  opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
52
52
  kdrfc.options.v3 = v
53
53
  end
54
+ opts.on("-2", "--[no-]v2", "Use RFCXML v2 processing rules") do |v|
55
+ kdrfc.options.v2 = v
56
+ end
54
57
  end
55
58
  op.parse!
56
59
 
60
+
61
+ if kdrfc.options.v2 && kdrfc.options.v3
62
+ warn "*** can't have v2 and eat v3 cake"
63
+ kdrfc.options.v2 = false
64
+ end
65
+
66
+ if kdrfc.options.v3.nil? && !kdrfc.options.v2
67
+ if Time.now.to_i >= 1645567342 # Time.parse("2022-02-22T22:02:22Z").to_i
68
+ kdrfc.options.v3 = true # new default from the above date
69
+ end
70
+ end
71
+
72
+ warn "*** v2 #{kdrfc.options.v2.inspect} v3 #{kdrfc.options.v3.inspect}" if kdrfc.options.verbose
73
+
57
74
  case ARGV.size
58
75
  when 1
59
76
  fn = ARGV[0]
data/bin/kramdown-rfc ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'ostruct'
4
+
5
+ $options ||= OpenStruct.new
6
+
7
+ $options.v3 = true
8
+ require 'kramdown-rfc/command'
9
+
data/bin/kramdown-rfc2629 CHANGED
@@ -1,528 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- require 'kramdown-rfc2629'
4
- require 'kramdown-rfc/parameterset'
5
- require 'kramdown-rfc/refxml'
6
- require 'kramdown-rfc/rfc8792'
7
- require 'yaml'
8
- require 'kramdown-rfc/erb'
9
- require 'date'
3
+ require 'kramdown-rfc/command'
10
4
 
11
- # try to get this from gemspec.
12
- KDRFC_VERSION=Gem.loaded_specs["kramdown-rfc2629"].version rescue "unknown-version"
13
-
14
- Encoding.default_external = "UTF-8" # wake up, smell the coffee
15
-
16
- # Note that this doesn't attempt to handle HT characters
17
- def remove_indentation(s)
18
- l = s.lines
19
- indent = l.grep(/\S/).map {|l| l[/^\s*/].size}.min
20
- l.map {|li| li.sub(/^ {0,#{indent}}/, "")}.join
21
- end
22
-
23
- def add_quote(s)
24
- l = s.lines
25
- l.map {|li| "> #{li}"}.join
26
- end
27
-
28
- def process_chunk(s, dedent, fold, quote)
29
- s = remove_indentation(s) if dedent
30
- s = fold8792_1(s) if fold
31
- s = add_quote(s) if quote
32
- s
33
- end
34
-
35
- def boilerplate(key)
36
- case key.downcase
37
- when /\Abcp14(info)?(\+)?(-tagged)?\z/i
38
- ret = ''
39
- if $1
40
- ret << <<RFC8174ise
41
- Although this document is not an IETF Standards Track publication, it
42
- adopts the conventions for normative language to provide clarity of
43
- instructions to the implementer.
44
- RFC8174ise
45
- end
46
- ret << <<RFC8174
47
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
48
- NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
49
- "MAY", and "OPTIONAL" in this document are to be interpreted as
50
- described in BCP 14 {{!RFC2119}} {{!RFC8174}} when, and only when, they
51
- appear in all capitals, as shown here.
52
- RFC8174
53
- if $2
54
- ret << <<PLUS
55
- These words may also appear in this document in
56
- lower case as plain English words, absent their normative meanings.
57
- PLUS
58
- end
59
- if $3
60
- if $options.v3
61
- ret << <<TAGGED
62
-
63
- *[MUST]: <bcp14>
64
- *[MUST NOT]: <bcp14>
65
- *[REQUIRED]: <bcp14>
66
- *[SHALL]: <bcp14>
67
- *[SHALL NOT]: <bcp14>
68
- *[SHOULD]: <bcp14>
69
- *[SHOULD NOT]: <bcp14>
70
- *[RECOMMENDED]: <bcp14>
71
- *[NOT RECOMMENDED]: <bcp14>
72
- *[MAY]: <bcp14>
73
- *[OPTIONAL]: <bcp14>
74
- TAGGED
75
- else
76
- warn "** need --v3 to tag bcp14"
77
- end
78
- end
79
- ret
80
- else
81
- warn "** Unknwon boilerplate key: #{key}"
82
- "{::boilerplate #{key}}"
83
- end
84
- end
85
-
86
- def do_the_tls_dance
87
- begin
88
- require 'openssl'
89
- File.open(OpenSSL::X509::DEFAULT_CERT_FILE) do end
90
- # This guards against having an unreadable cert file (yes, that appears to happen a lot).
91
- rescue
92
- if Dir[File.join(OpenSSL::X509::DEFAULT_CERT_DIR, "*.pem")].empty?
93
- # This guards against having no certs at all, not against missing the right one for IETF.
94
- # Oh well.
95
- warn "** Configuration problem with OpenSSL certificate store."
96
- warn "** You may want to examine #{OpenSSL::X509::DEFAULT_CERT_FILE}"
97
- warn "** and #{OpenSSL::X509::DEFAULT_CERT_DIR}."
98
- warn "** Activating suboptimal workaround."
99
- warn "** Occasionally run `certified-update` to maintain that workaround."
100
- require 'certified'
101
- end
102
- end
103
- end
104
-
105
- RE_NL = /(?:\n|\r|\r\n)/
106
- RE_SECTION = /---(?: +(\w+)(-?))?\s*#{RE_NL}(.*?#{RE_NL})(?=---(?:\s+\w+-?)?\s*#{RE_NL}|\Z)/m
107
-
108
- NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
109
-
110
- NORMINFORM = { "!" => :normative, "?" => :informative }
111
-
112
- def yaml_load(input, *args)
113
- if YAML.respond_to?(:safe_load)
114
- begin
115
- YAML.safe_load(input, *args)
116
- rescue ArgumentError
117
- YAML.safe_load(input, permitted_classes: args[0], permitted_symbols: args[1], aliases: args[2])
118
- end
119
- else
120
- YAML.load(input)
121
- end
122
- end
123
-
124
- def process_kramdown_options(coding_override = nil,
125
- smart_quotes = nil, typographic_symbols = nil,
126
- header_kramdown_options = nil)
127
-
128
- ascii_target = coding_override && coding_override =~ /ascii/
129
- suppress_typography = ascii_target || $options.v3
130
- entity_output = ascii_target ? :numeric : :as_char;
131
-
132
- options = {input: 'RFC2629Kramdown', entity_output: entity_output, link_defs: {}}
133
-
134
- if smart_quotes.nil? && suppress_typography
135
- smart_quotes = false
136
- end
137
- if smart_quotes == false
138
- smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
139
- end
140
- case smart_quotes
141
- when Array
142
- options[:smart_quotes] = smart_quotes
143
- when nil, true
144
- # nothin
145
- else
146
- warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
147
- end
148
-
149
- if typographic_symbols.nil? && suppress_typography
150
- typographic_symbols = false
151
- end
152
- if typographic_symbols == false
153
- typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
154
- if Symbol === v
155
- [v.intern, k]
156
- end
157
- }.compact]
158
- end
159
- # warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
160
- case typographic_symbols
161
- when Hash
162
- options[:typographic_symbols] = typographic_symbols
163
- when nil, true
164
- # nothin
165
- else
166
- warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
167
- end
168
-
169
- if header_kramdown_options
170
- options.merge! header_kramdown_options
171
- end
172
-
173
- $global_markdown_options = options # For nested calls in bibref annotation processing and xref text
174
-
175
- options
176
- end
177
-
178
- XREF_SECTIONS_RE = ::Kramdown::Parser::RFC2629Kramdown::SECTIONS_RE
179
- XSR_PREFIX = "#{XREF_SECTIONS_RE} of "
180
- XSR_SUFFIX = ", (#{XREF_SECTIONS_RE})| \\((#{XREF_SECTIONS_RE})\\)"
181
- XREF_TXT = ::Kramdown::Parser::RFC2629Kramdown::XREF_TXT
182
- XREF_TXT_SUFFIX = " \\(#{XREF_TXT}\\)"
183
-
184
- def spacify_re(s)
185
- s.gsub(' ', '[\u00A0\s]+')
186
- end
187
-
188
- def xml_from_sections(input)
189
-
190
- unless ENV["KRAMDOWN_NO_SOURCE"]
191
- require 'kramdown-rfc/gzip-clone'
192
- require 'base64'
193
- compressed_input = Gzip.compress(input)
194
- $source = Base64.encode64(compressed_input)
195
- end
196
-
197
- sections = input.scan(RE_SECTION)
198
- # resulting in an array; each section is [section-label, nomarkdown-flag, section-text]
199
-
200
- # the first section is a YAML with front matter parameters (don't put a label here)
201
- # We put back the "---" plus gratuitous blank lines to hack the line number in errors
202
- yaml_in = input[/---\s*/] << sections.shift[2]
203
- ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
204
-
205
- coding_override = ps.has(:coding)
206
- smart_quotes = ps[:smart_quotes]
207
- typographic_symbols = ps[:typographic_symbols]
208
- header_kramdown_options = ps[:kramdown_options]
209
-
210
- kramdown_options = process_kramdown_options(coding_override,
211
- smart_quotes, typographic_symbols,
212
- header_kramdown_options)
213
-
214
- # all the other sections are put in a Hash, possibly concatenated from parts there
215
- sechash = Hash.new{ |h,k| h[k] = ""}
216
- snames = [] # a stack of section names
217
- sections.each do |sname, nmdflag, text|
218
- # warn [:SNAME, sname, nmdflag, text[0..10]].inspect
219
- nmdin, nmdout = {
220
- "-" => ["", ""], # stay in nomarkdown
221
- "" => NMDTAGS, # pop out temporarily
222
- }[nmdflag || ""]
223
- if sname
224
- snames << sname # "--- label" -> push label (now current)
225
- else
226
- snames.pop # just "---" -> pop label (previous now current)
227
- end
228
- sechash[snames.last] << "#{nmdin}#{text}#{nmdout}"
229
- end
230
-
231
- ref_replacements = { }
232
- anchor_to_bibref = { }
233
-
234
- [:ref, :normative, :informative].each do |sn|
235
- if refs = ps.has(sn)
236
- warn "*** bad section #{sn}: #{refs.inspect}" unless refs.respond_to? :each
237
- refs.each do |k, v|
238
- if v.respond_to? :to_str
239
- if bibtagsys(v) # enable "foo: RFC4711" as a custom anchor definition
240
- anchor_to_bibref[k] = v.to_str
241
- end
242
- ref_replacements[v.to_str] = k
243
- end
244
- if Hash === v
245
- if aliasname = v.delete("-")
246
- ref_replacements[aliasname] = k
247
- end
248
- if bibref = v.delete("=")
249
- anchor_to_bibref[k] = bibref
250
- end
251
- end
252
- end
253
- end
254
- end
255
- open_refs = ps[:ref] || { } # consumed
256
-
257
- norm_ref = { }
258
-
259
- # convenience replacement of {{-coap}} with {{I-D.ietf-core-coap}}
260
- # collect normative/informative tagging {{!RFC2119}} {{?RFC4711}}
261
- sechash.each do |k, v|
262
- next if k == "fluff"
263
- v.gsub!(/{{(#{
264
- spacify_re(XSR_PREFIX)
265
- })?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
266
- XREF_TXT_SUFFIX
267
- })?(#{
268
- spacify_re(XSR_SUFFIX)
269
- })?}}/) do |match|
270
- xsr_prefix = $1
271
- norminform = $2
272
- replacing = $3 || $4
273
- word = $5
274
- bibref = $6
275
- xrt_suffix = $7
276
- xsr_suffix = $8
277
- if replacing
278
- if new = ref_replacements[word]
279
- word = new
280
- else
281
- warn "*** no alias replacement for {{-#{word}}}"
282
- word = "-#{word}"
283
- end
284
- end # now, word is the anchor
285
- if bibref
286
- if old = anchor_to_bibref[word]
287
- if bibref != old
288
- warn "*** conflicting definitions for xref #{word}: #{old} != #{bibref}"
289
- end
290
- else
291
- anchor_to_bibref[word] = bibref
292
- end
293
- end
294
-
295
- # things can be normative in one place and informative in another -> normative
296
- # collect norm/inform above and assign it by priority here
297
- if norminform
298
- norm_ref[word] ||= norminform == '!' # one normative ref is enough
299
- end
300
- "{{#{xsr_prefix}#{word}#{xrt_suffix}#{xsr_suffix}}}"
301
- end
302
- end
303
-
304
- [:normative, :informative].each do |k|
305
- ps.rest[k.to_s] ||= { }
306
- end
307
-
308
- norm_ref.each do |k, v|
309
- # could check bibtagsys here: needed if open_refs is nil or string
310
- target = ps.has(v ? :normative : :informative)
311
- warn "*** overwriting #{k}" if target.has_key?(k)
312
- target[k] = open_refs[k] # add reference to normative/informative
313
- end
314
- # note that unused items from ref are considered OK, therefore no check for that here
315
-
316
- # also should allow norm/inform check of other references
317
- # {{?coap}} vs. {{!coap}} vs. {{-coap}} (undecided)
318
- # or {{?-coap}} vs. {{!-coap}} vs. {{-coap}} (undecided)
319
- # could require all references to be decided by a global flag
320
- overlap = [:normative, :informative].map { |s| (ps.has(s) || { }).keys }.reduce(:&)
321
- unless overlap.empty?
322
- warn "*** #{overlap.join(', ')}: both normative and informative"
323
- end
324
-
325
- stand_alone = ps[:stand_alone]
326
-
327
- [:normative, :informative].each do |sn|
328
- if refs = ps[sn]
329
- refs.each do |k, v|
330
- href = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(k)
331
- kramdown_options[:link_defs][k] = ["##{href}", nil] # allow [RFC2119] in addition to {{RFC2119}}
332
-
333
- bibref = anchor_to_bibref[k] || k
334
- bts, url = bibtagsys(bibref, k, stand_alone)
335
- if bts && (!v || v == {} || v.respond_to?(:to_str))
336
- if stand_alone
337
- a = %{{: anchor="#{k}"}}
338
- sechash[sn.to_s] << %{\n#{NMDTAGS[0]}\n![:include:](#{bts})#{a}\n#{NMDTAGS[1]}\n}
339
- else
340
- bts.gsub!('/', '_')
341
- (ps.rest["bibxml"] ||= []) << [bts, url]
342
- sechash[sn.to_s] << %{&#{bts};\n} # ???
343
- end
344
- else
345
- unless v && Hash === v
346
- warn "*** don't know how to expand ref #{k}"
347
- next
348
- end
349
- if bts && !v.delete("override")
350
- warn "*** warning: explicit settings completely override canned bibxml in reference #{k}"
351
- end
352
- sechash[sn.to_s] << KramdownRFC::ref_to_xml(href, v)
353
- end
354
- end
355
- end
356
- end
357
-
358
- erbfilename = File.expand_path '../../data/kramdown-rfc2629.erb', __FILE__
359
- erbfile = File.read(erbfilename, coding: "UTF-8")
360
- erb = ERB.trim_new(erbfile, '-')
361
- # remove redundant nomarkdown pop outs/pop ins as they confuse kramdown
362
- input = erb.result(binding).gsub(%r"{::nomarkdown}\s*{:/nomarkdown}"m, "")
363
- ps.warn_if_leftovers
364
- sechash.delete("fluff") # fluff is a "commented out" section
365
- if !sechash.empty? # any sections unused by the ERb file?
366
- warn "*** sections left #{sechash.keys.inspect}!"
367
- end
368
-
369
- [input, kramdown_options, coding_override]
370
- end
371
-
372
- XML_RESOURCE_ORG_PREFIX = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_PREFIX
373
-
374
- # return XML entity name, url, rewrite_anchor flag
375
- def bibtagsys(bib, anchor=nil, stand_alone=true)
376
- if bib =~ /\Arfc(\d+)/i
377
- rfc4d = "%04d" % $1.to_i
378
- [bib.upcase,
379
- "#{XML_RESOURCE_ORG_PREFIX}/bibxml/reference.RFC.#{rfc4d}.xml"]
380
- elsif $options.v3 && bib =~ /\A(bcp|std)(\d+)/i
381
- n4d = "%04d" % $2.to_i
382
- [bib.upcase,
383
- "#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries-new/reference.#{$1.upcase}.#{n4d}.xml"]
384
- elsif bib =~ /\A([-A-Z0-9]+)\./ &&
385
- (xro = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_MAP[$1])
386
- dir, _ttl, rewrite_anchor = xro
387
- bib1 = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(bib)
388
- if anchor && bib1 != anchor
389
- if rewrite_anchor
390
- a = %{?anchor=#{anchor}}
391
- else
392
- if !stand_alone
393
- warn "*** selecting a custom anchor '#{anchor}' for '#{bib1}' requires stand_alone mode"
394
- warn " the output will need manual editing to correct this"
395
- end
396
- end
397
- end
398
- [bib1,
399
- "#{XML_RESOURCE_ORG_PREFIX}/#{dir}/reference.#{bib}.xml#{a}"]
400
- end
401
- end
402
-
403
- def read_encodings
404
- encfilename = File.expand_path '../../data/encoding-fallbacks.txt', __FILE__
405
- encfile = File.read(encfilename, coding: "UTF-8")
406
- Hash[encfile.lines.map{|l|
407
- l.chomp!;
408
- x, s = l.split(" ", 2)
409
- [x.hex.chr(Encoding::UTF_8), s || " "]}]
410
- end
411
-
412
- FALLBACK = read_encodings
413
-
414
- def expand_tabs(s, tab_stops = 8)
415
- s.gsub(/([^\t\n]*)\t/) do
416
- $1 + " " * (tab_stops - ($1.size % tab_stops))
417
- end
418
- end
419
-
420
-
421
- require 'optparse'
422
- require 'ostruct'
423
-
424
- $options = OpenStruct.new
425
- op = OptionParser.new do |opts|
426
- opts.banner = <<BANNER
427
- Usage: kramdown-rfc2629 [options] file.md|file.mkd > file.xml
428
- Version: #{KDRFC_VERSION}
429
- BANNER
430
- opts.on("-V", "--version", "Show version and exit") do |v|
431
- puts "kramdown-rfc2629 #{KDRFC_VERSION}"
432
- exit
433
- end
434
- opts.on("-H", "--help", "Show option summary and exit") do |v|
435
- puts opts
436
- exit
437
- end
438
- opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
439
- $options.verbose = v
440
- end
441
- opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
442
- $options.v3 = v
443
- end
444
- end
445
- op.parse!
446
-
447
- if $options.verbose && $options.v3
448
- warn "*** not much RFCXMLv3 stuff implemented yet"
449
- end
450
-
451
- input = ARGF.read
452
- if input[0] == "\uFEFF"
453
- warn "*** There is a leading byte order mark. Ignored."
454
- input[0..0] = ''
455
- end
456
- if input[-1] != "\n"
457
- # warn "*** added missing newline at end"
458
- input << "\n" # fix #26
459
- end
460
- input.gsub!(/^\{::include((?:-[a-z]+)*)\s+(.*?)\}/) {
461
- include_flags = $1
462
- fn = [$2]
463
- chunks = false
464
- dedent = false
465
- fold = false
466
- quote = false
467
- include_flags.split("-") do |flag|
468
- case flag
469
- when ""
470
- when "quote"
471
- quote = true
472
- when "dedent"
473
- dedent = true
474
- when "fold"
475
- fold = true
476
- when "all", "last"
477
- fn = fn.flat_map{|n| Dir[n]}
478
- fn = [fn.last] if flag == "last"
479
- chunks = fn.map{ |f|
480
- ret = process_chunk(File.read(f), dedent, fold, quote)
481
- dedent = false; quote = false
482
- ret
483
- }
484
- else
485
- warn "** unknown include flag #{flag}"
486
- end
487
- end
488
- chunks = fn.map{|f| File.read(f)} unless chunks # no all/last
489
- chunks = chunks.map {|ch| process_chunk(ch, dedent, fold, quote)}
490
- chunks.join.chomp
491
- } unless ENV["KRAMDOWN_SAFE"]
492
- input.gsub!(/^\{::boilerplate\s+(.*?)\}/) {
493
- boilerplate($1)
494
- }
495
- if input =~ /[\t]/
496
- warn "*** Input contains HT (\"tab\") characters. Undefined behavior will ensue."
497
- input = expand_tabs(input)
498
- end
499
-
500
- if input =~ /\A---/ # this is a sectionized file
501
- do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
502
- input, options, coding_override = xml_from_sections(input)
503
- else
504
- options = process_kramdown_options # all default
505
- end
506
- if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
507
- input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
508
- end
509
-
510
- if coding_override
511
- input = input.encode(Encoding.find(coding_override), fallback: FALLBACK)
512
- end
513
-
514
- # 1.4.17: because of UTF-8 bibxml files, kramdown always needs to see UTF-8 (!)
515
- if input.encoding != Encoding::UTF_8
516
- input = input.encode(Encoding::UTF_8)
517
- end
518
-
519
- # warn "options: #{options.inspect}"
520
- doc = Kramdown::Document.new(input, options)
521
- $stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
522
- output = doc.to_rfc2629
523
-
524
- if coding_override
525
- output = output.encode(Encoding.find(coding_override), fallback: FALLBACK)
526
- end
527
-
528
- puts output
@@ -1,9 +1,18 @@
1
1
  <?xml version="1.0" encoding="<%=ps[:coding]||"UTF-8"%>"?>
2
2
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
3
3
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version <%=
4
- Gem.loaded_specs["kramdown-rfc2629"].version rescue nil %> -->
5
-
4
+ Gem.loaded_specs["kramdown-rfc2629"].version rescue nil
5
+ %> (Ruby <%= RUBY_VERSION %>) -->
6
+
7
+ <% if $options.v3 %>
8
+ <!DOCTYPE rfc <%= ps["doctype-reference"] %> [
9
+ <!ENTITY nbsp "&#160;">
10
+ <!ENTITY zwsp "&#8203;">
11
+ <!ENTITY nbhy "&#8209;">
12
+ <!ENTITY wj "&#8288;">
13
+ <% else %>
6
14
  <!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
15
+ <% end %>
7
16
  <% ps.arr("bibxml") do |tag, sys| -%>
8
17
  <!ENTITY <%= tag %> SYSTEM "<%= sys %>">
9
18
  <% end -%>
@@ -86,7 +95,10 @@
86
95
  <% if mail || homepage -%>
87
96
  <t>
88
97
  <% end -%>
89
- <% if mail && (mail_local, mail_host = mail.split("@", 2)) && mail_host -%>
98
+ <% if mail
99
+ mail_local, mail_host = mail.split("@", 2)
100
+ end
101
+ if mail_host -%>
90
102
  <% mail_subdomain, mail_domain = mail_host.split(".", 2) -%>
91
103
  <% group = venue[:group] || mail_local # XXX -%>
92
104
  <% arch = venue[:arch] || "https://mailarchive.ietf.org/arch/browse/#{mail_local}/" -%>
@@ -194,6 +206,7 @@
194
206
  <<CONTRIBUTION
195
207
  {:/nomarkdown}
196
208
  #{contrib}
209
+
197
210
  {::nomarkdown}
198
211
  CONTRIBUTION
199
212
  end -%>
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.5.22'
3
+ s.version = '1.6.1'
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.}
@@ -8,9 +8,9 @@ spec = Gem::Specification.new do |s|
8
8
  s.add_dependency('kramdown-parser-gfm', '~> 1.1')
9
9
  s.add_dependency('certified', '~> 1.0')
10
10
  s.add_dependency('json_pure', '~> 2.0')
11
- 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 bin/kramdown-rfc-cache-subseries-bibxml bin/de-gfm)
11
+ s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/de-gfm)
12
12
  s.require_path = 'lib'
13
- s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
13
+ s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
14
14
  'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
15
15
  'kramdown-rfc-cache-subseries-bibxml', 'de-gfm']
16
16
  s.required_ruby_version = '>= 2.3.0'