kramdown-rfc2629 1.6.43 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be23f7eeaf77c43ddf7a7c107f4d8b63fbb889e16c8e8bc2f884ee4bf8ed1beb
4
- data.tar.gz: 8e80fe90c56b9a6f71bcde89f7a2e2453723ce1c14ff5da318bf13aef1462aae
3
+ metadata.gz: 6fd72c01ed7024958d451c3342f16b8985dc145ef09a6e4d33ba2f3d290d81e4
4
+ data.tar.gz: 7ada0cb08e8481cfef450606bcfdaab0303a49b0306fdf5be7041121b57a1143
5
5
  SHA512:
6
- metadata.gz: 80ef5c32e66e82c1055a5c3fb5ededfb0d77545b7a9332490efe0eb21e5412786e7037cf0ce82878fccd9acb8b1e6773fc21c5ad5c365702c8eab02c3586511b
7
- data.tar.gz: 3bf117e47f149b84fc99b4c16ebd2df4e1f02d70cde17ece0a07017c96a169fba2a1e63404705610690ea6b2fd7cf0f328183cec34c90f3d8b812beb9442ffe4
6
+ metadata.gz: c525300de7bf414755c50476de45b9842ab011965a2dcfa82206d9e614a12b482b958707021dc3fff51a6c66f98b39b55d3dd6556d001ec255b50fde926a82e9
7
+ data.tar.gz: 200cb7e1760cc81b628354dc2343eaee5595294d1334b16d17b1e47ed3bc2f83174ee588d9e5d50289aebf0b0f579b4ad635124779cc66e5578bd600f4e17b9f
@@ -8,7 +8,8 @@ require_relative '../lib/kramdown-rfc/rexml-all-text.rb'
8
8
 
9
9
  def clean(s)
10
10
  s.gsub!(/\//, ":")
11
- s.gsub!(/[^:\w]/, "_") # handles leading dot, too -- s.gsub!(/\A([.]+)/) {"_" * $1.size } otherwise
11
+ s.gsub!(/\A([-.]+)/) {"_" * $1.size }
12
+ s.gsub!(/[^-.:\w]/, "_")
12
13
  s
13
14
  end
14
15
 
@@ -53,7 +54,10 @@ REXML::XPath.each(d.root, "//sourcecode|//artwork") do |x|
53
54
  if ty = x[:type]
54
55
  ty = clean(ty)
55
56
  name = x[:name]
56
- name = gensym.succ! if !name || name.empty?
57
+ if !name || name.empty?
58
+ name = gensym.succ!.dup
59
+ name = "#{name}.#{ty}" unless ty.empty?
60
+ end
57
61
  name = clean(name)
58
62
  if taken[ty][name]
59
63
  unless warned[ty][name]
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.6.43'
3
+ s.version = '1.7.2'
4
4
  s.summary = "Kramdown extension for generating RFCXML (RFC 799x)."
5
5
  s.description = %{An RFCXML (RFC 799x) generating backend for Thomas Leitner's
6
6
  "kramdown" markdown parser. Mostly useful for RFC writers.}
@@ -294,12 +294,6 @@ def xml_from_sections(input)
294
294
  if o = ps[:'svg-id-cleanup']
295
295
  $options.svg_id_cleanup = o
296
296
  end
297
- if o = ps[:'span-into']
298
- Array(o).each do |el|
299
- Kramdown::Parser::Html::Constants::HTML_CONTENT_MODEL[el] = :span
300
- warn Kramdown::Parser::Html::Constants::HTML_CONTENT_MODEL.inspect
301
- end
302
- end
303
297
 
304
298
  coding_override = ps.has(:coding)
305
299
  smart_quotes = ps[:smart_quotes] || ps[:"smart-quotes"]
@@ -366,18 +360,19 @@ warn Kramdown::Parser::Html::Constants::HTML_CONTENT_MODEL.inspect
366
360
  next if k == "fluff"
367
361
  v.gsub!(/{{(#{
368
362
  spacify_re(XSR_PREFIX)
369
- })?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
363
+ })?([\w.\/_\-]+@)?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
370
364
  XREF_TXT_SUFFIX
371
365
  })?(#{
372
366
  spacify_re(XSR_SUFFIX)
373
367
  })?}}/) do |match|
374
368
  xsr_prefix = $1
375
- norminform = $2
376
- replacing = $3 || $4
377
- word = $5
378
- bibref = $6
379
- xrt_suffix = $7
380
- xsr_suffix = $8
369
+ subref = $2
370
+ norminform = $3
371
+ replacing = $4 || $5
372
+ word = $6
373
+ bibref = $7
374
+ xrt_suffix = $8
375
+ xsr_suffix = $9
381
376
  if replacing
382
377
  if new = ref_replacements[word]
383
378
  word = new
@@ -401,7 +396,7 @@ warn Kramdown::Parser::Html::Constants::HTML_CONTENT_MODEL.inspect
401
396
  if norminform
402
397
  norm_ref[word] ||= norminform == '!' # one normative ref is enough
403
398
  end
404
- "{{#{xsr_prefix}#{word}#{xrt_suffix}#{xsr_suffix}}}"
399
+ "{{#{xsr_prefix}#{subref}#{word}#{xrt_suffix}#{xsr_suffix}}}"
405
400
  end
406
401
  end
407
402
 
@@ -78,6 +78,11 @@ module Kramdown
78
78
  href.gsub(/\A(?:[0-9]|section-|u-|figure-|table-|iref-)/) { "_#{$&}" }
79
79
  end
80
80
 
81
+ def rfc_mention(target1) # only works for RFCnnnn
82
+ target1 =~ /\A([A-Z]*)(.*)\z/
83
+ "#$1 #$2 "
84
+ end
85
+
81
86
  def handle_bares(s, attr, format, href, last_join = nil)
82
87
  if s.match(/\A(#{XREF_ANY}) and (#{XREF_ANY})\z/)
83
88
  handle_bares($1, {}, nil, href, " and ")
@@ -86,13 +91,14 @@ module Kramdown
86
91
  end
87
92
 
88
93
  href = href.split(' ')[0] # Remove any trailing (...)
94
+ target1, target2 = href.split("@", 2)
89
95
  multi = last_join != nil
90
96
  (sn, s) = s.split(' ', 2)
91
97
  loop do
92
98
  m = s.match(/\A#{XREF_RE_M}(, (?:and )?| and )?/)
93
99
  break if not m
94
100
 
95
- if not multi and not m[2] and not m[3]
101
+ if not multi and not m[2] and not m[3] and not target2
96
102
  # Modify |attr| if there is a single reference. This can only be
97
103
  # used if there is only one section reference and the section part
98
104
  # has no title.
@@ -110,9 +116,13 @@ module Kramdown
110
116
  multi = true
111
117
  s[m[0]] = ''
112
118
 
113
- attr1 = { 'target' => href, 'section' => m[1], 'sectionFormat' => 'bare', 'text' => m[2] }
119
+ attr1 = { 'target' => target1, 'section' => m[1], 'sectionFormat' => 'bare', 'text' => m[2] }
114
120
  @tree.children << Element.new(:xref, nil, attr1)
115
- @tree.children << Element.new(:text, m[3] || last_join || " of ", {})
121
+ andof = m[3] || last_join || " of "
122
+ if andof == " of " && target2
123
+ andof += rfc_mention(target1)
124
+ end
125
+ @tree.children << Element.new(:text, andof, {})
116
126
  end
117
127
  end
118
128
 
@@ -135,18 +145,22 @@ module Kramdown
135
145
  else
136
146
  href = @src[3]
137
147
  attr = {}
148
+ handled_subref = false
138
149
  if $options.v3
139
150
  # match Section ... of ...; set section, sectionFormat
140
151
  case href.gsub(/[\u00A0\s]+/, ' ') # may need nbsp and/or newlines
141
152
  when /\A(#{SECTIONS_RE}) of (.*)\z/
142
153
  href = $2
143
154
  handle_bares($1, attr, "of", href)
155
+ handled_subref = true
144
156
  when /\A(.*), (#{SECTIONS_RE})\z/
145
157
  href = $1
146
158
  handle_bares($2, attr, "comma", href)
159
+ handled_subref = true
147
160
  when /\A(.*) \((#{SECTIONS_RE})\)\z/
148
161
  href = $1
149
162
  handle_bares($2, attr, "parens", href)
163
+ handled_subref = true
150
164
  when /#{XREF_RE_M}<(.+)\z/
151
165
  href = $3
152
166
  if $2
@@ -168,6 +182,13 @@ module Kramdown
168
182
  href = $1
169
183
  attr['text'] = $2
170
184
  end
185
+ target1, target2 = href.split("@", 2) # should do this only for sectionref...
186
+ if target2
187
+ href = target2
188
+ unless handled_subref
189
+ @tree.children << Element.new(:text, rfc_mention(target1), {})
190
+ end
191
+ end
171
192
  href = self.class.idref_cleanup(href)
172
193
  attr['target'] = href
173
194
  el = Element.new(:xref, nil, attr)
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.6.43
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-23 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown