kramdown-rfc2629 1.7.1 → 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: bd5a2c0f3273c06c40f191cba73edff87064b7b07ff90eb28dbf50ff5128f476
4
- data.tar.gz: 9a0a8949db295d24fc6cb7374b6438d3113e9ee84f465d3de4918d18ef1fac52
3
+ metadata.gz: 6fd72c01ed7024958d451c3342f16b8985dc145ef09a6e4d33ba2f3d290d81e4
4
+ data.tar.gz: 7ada0cb08e8481cfef450606bcfdaab0303a49b0306fdf5be7041121b57a1143
5
5
  SHA512:
6
- metadata.gz: 735f79f81ac9cb0e19fd06362a79dffe6b5e73e06d658c11b0e62439c8c9b66b40f19252c756a3d5fc592b709d70342ed5ec4c290260d7fd0b9ce080e76c2e67
7
- data.tar.gz: bf6e459bd077b13b87baee248e4a76f0287833fcbb49d00f009ce5871cc1133742a67c5bf8f1c3d9cdaf27387235e6e464c4043afb863436726f2a49d71a529b
6
+ metadata.gz: c525300de7bf414755c50476de45b9842ab011965a2dcfa82206d9e614a12b482b958707021dc3fff51a6c66f98b39b55d3dd6556d001ec255b50fde926a82e9
7
+ data.tar.gz: 200cb7e1760cc81b628354dc2343eaee5595294d1334b16d17b1e47ed3bc2f83174ee588d9e5d50289aebf0b0f579b4ad635124779cc66e5578bd600f4e17b9f
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.7.1'
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.}
@@ -360,18 +360,19 @@ def xml_from_sections(input)
360
360
  next if k == "fluff"
361
361
  v.gsub!(/{{(#{
362
362
  spacify_re(XSR_PREFIX)
363
- })?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
363
+ })?([\w.\/_\-]+@)?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
364
364
  XREF_TXT_SUFFIX
365
365
  })?(#{
366
366
  spacify_re(XSR_SUFFIX)
367
367
  })?}}/) do |match|
368
368
  xsr_prefix = $1
369
- norminform = $2
370
- replacing = $3 || $4
371
- word = $5
372
- bibref = $6
373
- xrt_suffix = $7
374
- 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
375
376
  if replacing
376
377
  if new = ref_replacements[word]
377
378
  word = new
@@ -395,7 +396,7 @@ def xml_from_sections(input)
395
396
  if norminform
396
397
  norm_ref[word] ||= norminform == '!' # one normative ref is enough
397
398
  end
398
- "{{#{xsr_prefix}#{word}#{xrt_suffix}#{xsr_suffix}}}"
399
+ "{{#{xsr_prefix}#{subref}#{word}#{xrt_suffix}#{xsr_suffix}}}"
399
400
  end
400
401
  end
401
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.7.1
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-27 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