kramdown-rfc2629 1.4.17 → 1.4.18

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: 995b589ce86783d0aa3f5e3193cdb0399ace572b239fade7995c5699f6e4f8de
4
- data.tar.gz: ea44d32db3e9c9a57210da431859ede63d5a2d756dd05f0beee9bbc1722e2cc3
3
+ metadata.gz: f351fb251c634da227a9ce9202094ee20ac11689be7b2144f118ba07aa2b31fb
4
+ data.tar.gz: 45d0559f1f6c6ff2c4ba18bab26a4e88bec8faad622cf0b9183c144eb419441f
5
5
  SHA512:
6
- metadata.gz: 8e51f7d06bc29eb1cef1c475443f207474e23e903e0b9880ec29507a902aba034407821dbfa177aca297905571a6f404e651eefb62005bea55715fed885dd575
7
- data.tar.gz: fccef7a2f854bebea02100f3dea2ab5c5cbcd0800f2bcd83272869d40255d1455aa76ecc5137e78c22f4871b4971acbbc02a00b7656a12cd595ebe1444447fb7
6
+ metadata.gz: 2d3acf198070f8d7b69995f9f581302a6d20bbb24241350a169ef8cc5ccfeb49d191adfaaa11442df5859534812761d91c7f7c5a8b22b5a2aec19c8d2a02e48b
7
+ data.tar.gz: b1c5d6d9c968d82a453bcdfcc234e1dc4f3844ba9084942f73fd5212258d0d1e361f55fc1cb36910b58a4c2e68286cfe20695cf8d6d1c9e538a9907164d89d71
data/README.md CHANGED
@@ -317,6 +317,10 @@ Note that this feature does not play well with the CI (continuous
317
317
  integration) support in Martin Thomson's [I-D Template][], as that may
318
318
  not have the tools installed in its docker instance.
319
319
 
320
+ More details have been collected on the [wiki][svg].
321
+
322
+ [svg]: https://github.com/cabo/kramdown-rfc2629/wiki/SVG
323
+
320
324
  (1.2.9:)
321
325
  The YAML header now allows specifying [kramdown_options][].
322
326
 
data/bin/kramdown-rfc2629 CHANGED
@@ -83,7 +83,7 @@ def do_the_tls_dance
83
83
  end
84
84
 
85
85
  RE_NL = /(?:\n|\r|\r\n)/
86
- RE_SECTION = /---(?:\s+(\w+)(-?))?\s*#{RE_NL}(.*?#{RE_NL})(?=---(?:\s+\w+-?)?\s*#{RE_NL}|\Z)/m
86
+ RE_SECTION = /---(?: +(\w+)(-?))?\s*#{RE_NL}(.*?#{RE_NL})(?=---(?:\s+\w+-?)?\s*#{RE_NL}|\Z)/m
87
87
 
88
88
  NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
89
89
 
@@ -195,6 +195,7 @@ def xml_from_sections(input)
195
195
  sechash = Hash.new{ |h,k| h[k] = ""}
196
196
  snames = [] # a stack of section names
197
197
  sections.each do |sname, nmdflag, text|
198
+ # warn [:SNAME, sname, nmdflag, text[0..10]].inspect
198
199
  nmdin, nmdout = {
199
200
  "-" => ["", ""], # stay in nomarkdown
200
201
  "" => NMDTAGS, # pop out temporarily
@@ -306,7 +307,7 @@ def xml_from_sections(input)
306
307
  [:normative, :informative].each do |sn|
307
308
  if refs = ps[sn]
308
309
  refs.each do |k, v|
309
- href = k.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
310
+ href = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(k)
310
311
  kramdown_options[:link_defs][k] = ["##{href}", nil] # allow [RFC2119] in addition to {{RFC2119}}
311
312
 
312
313
  bibref = anchor_to_bibref[k] || k
@@ -363,7 +364,7 @@ def bibtagsys(bib, anchor=nil, stand_alone=true)
363
364
  elsif bib =~ /\A([-A-Z0-9]+)\./ &&
364
365
  (xro = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_MAP[$1])
365
366
  dir, _ttl, rewrite_anchor = xro
366
- bib1 = bib.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an ID with a number
367
+ bib1 = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(bib)
367
368
  if anchor && bib1 != anchor
368
369
  if rewrite_anchor
369
370
  a = %{?anchor=#{anchor}}
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.4.17'
3
+ s.version = '1.4.18'
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.}
@@ -42,7 +42,7 @@ module Kramdown
42
42
  @block_parsers.unshift(:block_pi)
43
43
  end
44
44
 
45
- XREF_BASE = /[\w.-]+/ # a token for a reference
45
+ XREF_BASE = /#{REXML::XMLTokens::NAME_CHAR}+/ # a token for a reference
46
46
  XREF_TXT = /(?:[^\(]|\([^\)]*\))+/ # parenthesized text
47
47
  XREF_RE = /#{XREF_BASE}(?: \(#{XREF_TXT}\))?/
48
48
  XREF_RE_M = /\A(#{XREF_BASE})(?: \((#{XREF_TXT})\))?/ # matching version of XREF_RE
@@ -51,6 +51,11 @@ module Kramdown
51
51
  XREF_ANY = /(?:#{XREF_SINGLE}|#{XREF_MULTI})/
52
52
  SECTIONS_RE = /(?:#{XREF_ANY} and )?#{XREF_ANY}/
53
53
 
54
+ def self.idref_cleanup(href)
55
+ # can't start an IDREF with a number or reserved start
56
+ href.gsub(/\A(?:[0-9]|section-|u-|figure-|table-|iref-)/) { "_#{$&}" }
57
+ end
58
+
54
59
  def handle_bares(s, attr, format, href, last_join = nil)
55
60
  if s.match(/\A(#{XREF_ANY}) and (#{XREF_ANY})\z/)
56
61
  handle_bares($1, {}, nil, href, " and ")
@@ -132,11 +137,11 @@ module Kramdown
132
137
  attr['format'] = 'counter'
133
138
  end
134
139
  end
135
- if href.match(XREF_RE_M)
140
+ if href.match(/#{XREF_RE_M}\z/)
136
141
  href = $1
137
142
  attr['text'] = $2
138
143
  end
139
- href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
144
+ href = self.class.idref_cleanup(href)
140
145
  attr['target'] = href
141
146
  el = Element.new(:xref, nil, attr)
142
147
  end
@@ -212,10 +217,10 @@ module Kramdown
212
217
  def rfc2629_fix
213
218
  if a = attr
214
219
  if anchor = a.delete('id')
215
- a['anchor'] = anchor
220
+ a['anchor'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
216
221
  end
217
222
  if anchor = a.delete('href')
218
- a['target'] = anchor
223
+ a['target'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
219
224
  end
220
225
  attr.keys.each do |k|
221
226
  if (d = k.gsub(/_(.|$)/) { $1.upcase }) != k or d = STUDLY_ATTR_MAP[k]
@@ -959,7 +964,7 @@ COLORS
959
964
  warn "*** missing anchor for '#{src}'"
960
965
  src
961
966
  )
962
- anchor.sub!(/\A[0-9]/) { "_#{$&}" } # can't start an ID with a number
967
+ anchor = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
963
968
  anchor.gsub!('/', '_') # should take out all illegals
964
969
  to_insert = ""
965
970
  src.scan(/(W3C|3GPP|[A-Z-]+)[.]?([A-Za-z_0-9.\/\+-]+)/) do |t, n|
@@ -1028,7 +1033,7 @@ COLORS
1028
1033
  # "\n#{' '*indent}<cref>\n#{inner(el.value, indent, opts).rstrip}\n#{' '*indent}</cref>"
1029
1034
  content = inner(el.value, indent, opts).strip
1030
1035
  content = escape_html(content.sub(/\A<t>(.*)<\/t>\z/m) {$1}, :text) # text only...
1031
- name = el.options[:name].sub(/\A[0-9]/) {"_" << $&}
1036
+ name = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(el.options[:name])
1032
1037
  while @footnote_names_in_use[name] do
1033
1038
  if name =~ /:\d+\z/
1034
1039
  name.succ!
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.17
4
+ version: 1.4.18
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-06-18 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown