kramdown-rfc2629 1.7.3 → 1.7.5

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: cb7b62deaf23ec115b6b5b470e27bc099169d24ec1b09cd78e39a53f710d0319
4
- data.tar.gz: 28ceab4f96a1c33dee2ab4c53ae4423069bb5f9d6f61e55a69ec8a1991b8109e
3
+ metadata.gz: c4312704a187b582d3529a40e9823be50ad351fed98b6e29ab808098c56f9a0b
4
+ data.tar.gz: 27b76a9e2993053e0833e26989d97c074a0a3dcae3b47fd40d1aeaa96d928620
5
5
  SHA512:
6
- metadata.gz: 5e95b5dcecb044404550dc3f481581d7cd044e4738b805cd8156c217910cf22a5e69f50b0c5bfc907d2f10c58c568d8eb8856924e4a0ca84429861a1ea0429ef
7
- data.tar.gz: e0298c6433e0063aad63e04336f4f4f722ff878d053a565efc2502b3de35a286388952c68ca72805b32f1322b9f71c541fae8f0a80ce22a5532817ac1327f816
6
+ metadata.gz: c759b0acce805b13a263ec9b7246524a880715ff347d2b55e804a068c267dac09dc4bbc0630fc397ccdf364dd1b33102eff048729acacb271601b161502365c1
7
+ data.tar.gz: 4fb895add0affa38a4504c0e610676cef702a336e4377fee1142b41ddf1f83541ec64084aceb103857d944a14680561b53d19327d4661b15ae65e65de5b7b67e
data/README.md CHANGED
@@ -475,8 +475,8 @@ allow for automatic entry of items as normative/informative.
475
475
  (1.0.16:) Markdown footnotes are converted into `cref`s (XML2RFC formal
476
476
  comments; note that these are only visible if the pi "comments" is set to yes).
477
477
  The anchor is taken from the markdown footnote name. The source, if
478
- needed, can be supplied by an IAD, as in (first example with
479
- ALD):
478
+ needed, can be supplied by an [IAL][], as in (first example also uses an
479
+ [ALD][]):
480
480
 
481
481
  ```markdown
482
482
  {:cabo: source="cabo"}
@@ -494,7 +494,7 @@ Note that XML2RFC v2 doesn't allow structure in crefs. If you put any,
494
494
  you get the escaped verbatim XML...
495
495
 
496
496
  (1.0.11:) Allow overriding "style" attribute (via IAL =
497
- [inline attribute list][kdsyntax-ial]) in lists and spans
497
+ [inline attribute list][IAL]) in lists and spans
498
498
  as in:
499
499
 
500
500
  ```markdown
@@ -549,8 +549,9 @@ note that this creates ugly blank space in some HTML converters).
549
549
 
550
550
  # Risks and Side-Effects
551
551
 
552
- The code is not very polished, but now quite stable; it has been successfully used for a
553
- number of non-trivial Internet-Drafts and RFCs. You probably still need to
552
+ The code is not very polished, but now quite stable; it has been
553
+ successfully used for hundreds of non-trivial Internet-Drafts and RFCs.
554
+ You probably still need to
554
555
  skim [v3][] if you want to write an Internet-Draft, but you
555
556
  don't really need to understand XML very much. Knowing the basics of
556
557
  YAML helps with the metadata (but you'll understand it from the
@@ -563,12 +564,29 @@ This can for instance be used to obtain unnumbered appendices:
563
564
  ```markdown
564
565
  Acknowledgements
565
566
  ================
566
- {: numbered="no"}
567
+ {: numbered="false"}
568
+
569
+ John Mattsson was nice enough to point out the need for this being documented.
570
+ ```
571
+
572
+
573
+ Note that this specific example is covered by a predefined
574
+ kramdown-rfc ["attribute list definition" (ALD)][ALD]:
575
+
576
+ ```markdown
577
+ {:unnumbered: numbered="false"}
578
+ ```
579
+
580
+ so the conventional way to write this example would be the somewhat simpler:
581
+
582
+ ```markdown
583
+ Acknowledgements
584
+ ================
585
+ {:unnumbered}
567
586
 
568
587
  John Mattsson was nice enough to point out the need for this being documented.
569
588
  ```
570
589
 
571
- [IAL]: https://kramdown.gettalong.org/syntax.html#inline-attribute-lists
572
590
 
573
591
  # Upconversion
574
592
 
@@ -638,7 +656,8 @@ made it possible to license kramdown-rfc under the same license.
638
656
 
639
657
  [kramdown]: https://kramdown.gettalong.org
640
658
  [kdsyntax]: http://kramdown.gettalong.org/syntax.html
641
- [kdsyntax-ial]: http://kramdown.gettalong.org/syntax.html#inline-attribute-lists
659
+ [IAL]: https://kramdown.gettalong.org/syntax.html#inline-attribute-lists
660
+ [ALD]: https://kramdown.gettalong.org/syntax.html#attribute-list-definitions
642
661
  [stupid]: http://tools.ietf.org/id/draft-hartke-xmpp-stupid-00
643
662
  [RFC 2629]: https://www.rfc-editor.org/rfc/rfc2629.html
644
663
  [RFC 7749]: https://www.rfc-editor.org/rfc/rfc7749.html
@@ -9,10 +9,35 @@ require_relative '../lib/kramdown-rfc/rexml-all-text.rb'
9
9
  def clean(s)
10
10
  s.gsub!(/\//, ":")
11
11
  s.gsub!(/\A([-.]+)/) {"_" * $1.size }
12
- s.gsub!(/[^-.:\w]/, "_")
12
+ s.gsub!(/[^-.:\w]+/, "-")
13
13
  s
14
14
  end
15
15
 
16
+ $seen_slugs = {}
17
+
18
+ def slugify_like_xml2rfc(s, delta = 0)
19
+ s = s.unicode_normalize(:nfkd).force_encoding(Encoding::ASCII).scrub('').downcase
20
+ s.gsub!(/[^-\w\s\/]/, '')
21
+ s = s.strip
22
+ s.gsub!(/[-\s\/]/, '-')
23
+ n = 32 - delta
24
+ nmax = [s.size, 40 - delta].min
25
+ while $seen_slugs[slugex = s[0...n]] && n < nmax
26
+ n += 1
27
+ end
28
+ if $seen_slugs[slugex]
29
+ m = 2
30
+ while $seen_slugs[slugex = "#{s[0...n]}-#{m}"]
31
+ m += 1
32
+ if m == 1000
33
+ raise ArgumentError, "Can't build distinguishable slug for '#{s}'"
34
+ end
35
+ end
36
+ end
37
+ $seen_slugs[slugex] = s
38
+ slugex
39
+ end
40
+
16
41
  target = nil
17
42
  dir = nil
18
43
  unfold = true
@@ -52,17 +77,54 @@ warned = Hash.new { |h, k| h[k] = Hash.new }
52
77
  d = REXML::Document.new(ARGF)
53
78
  REXML::XPath.each(d.root, "//sourcecode|//artwork") do |x|
54
79
  if ty = x[:type]
80
+ is_svg = false
81
+ REXML::XPath.each(x, "svg") do is_svg = true end
55
82
  ty = clean(ty)
83
+ if is_svg && ty != "svg"
84
+ warn "** replacing SVG type '#{ty}' by type 'svg'"
85
+ ty = "svg"
86
+ end
87
+ ext = ty
88
+ if ty.empty?
89
+ ty = "=txt"
90
+ ext = "txt"
91
+ end
56
92
  name = x[:name]
93
+ name_is_from_slug = false
57
94
  if !name || name.empty?
58
- name = gensym.succ!.dup
59
- name = "#{name}.#{ty}" unless ty.empty?
95
+ REXML::XPath.each(x, "ancestor::*/name[position() = 1]") do |nameel|
96
+ unless sname = nameel['slugifiedName']
97
+ alltext = nameel.all_text
98
+ nameel.add_attribute('slugifiedName',
99
+ sname = clean("name-" << slugify_like_xml2rfc(alltext, 5)))
100
+ end
101
+ name = clean(sname.to_s.sub(/^name-/, ''))
102
+ name_is_from_slug = true
103
+ end
104
+ if !name || name.empty?
105
+ name = gensym.succ!.dup
106
+ end
107
+ name = "#{name}.#{ext}"
60
108
  end
61
109
  name = clean(name)
62
110
  if taken[ty][name]
63
- unless warned[ty][name]
64
- warn "Concatenating to #{ty}/#{name}."
65
- warned[ty][name] = true
111
+ if name_is_from_slug || is_svg
112
+ # rename old entry as well if it was from slug?
113
+ nameparts = name.split(".")
114
+ if is_svg && nameparts[-1] != "svg"
115
+ nameparts << "svg"
116
+ end
117
+ ext1 = nameparts.pop || "txt"
118
+ suffix = "b"
119
+ while taken[ty][name = [*nameparts[0...-1], "#{nameparts[-1]}-#{suffix}", ext1].join(".")]
120
+ suffix.succ!
121
+ end
122
+ taken[ty][name] = ''
123
+ else
124
+ unless warned[ty][name]
125
+ warn "Concatenating to #{ty}/#{name}."
126
+ warned[ty][name] = true
127
+ end
66
128
  end
67
129
  else
68
130
  taken[ty][name] = ''
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.7.3'
3
+ s.version = '1.7.5'
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.}
@@ -40,11 +40,19 @@ module KramdownRFC
40
40
  def attr(pn)
41
41
  val, an = van(pn)
42
42
  @av[an.intern] = val
43
- %{#{an}="#{escattr(val)}"} if val
43
+ %{#{an}="#{escattr(val)}"} if val # see attrtf below
44
44
  end
45
45
  def attrs(*pns)
46
46
  pns.map{ |pn| attr(pn) if pn }.compact.join(" ")
47
47
  end
48
+ def attrtf(pn) # can do an overriding false value
49
+ val, an = van(pn)
50
+ @av[an.intern] = val
51
+ %{#{an}="#{escattr(val)}"} unless val.nil?
52
+ end
53
+ def attrstf(*pns)
54
+ pns.map{ |pn| attrtf(pn) if pn }.compact.join(" ")
55
+ end
48
56
  def ele(pn, attr=nil, defcontent=nil, markdown=false)
49
57
  val, an = van(pn)
50
58
  val ||= defcontent
@@ -17,7 +17,8 @@ module KramdownRFC
17
17
  def self.ref_to_xml(k, v)
18
18
  vps = KramdownRFC::ParameterSet.new(v)
19
19
  erb = ERB.trim_new <<-REFERB, '-'
20
- <reference anchor="<%= escattr(k) %>" <%= vps.attr("target") %>>
20
+ <reference anchor="<%= escattr(k) %>" <%=
21
+ vps.attrstf("target", "quoteTitle=quote-title=quotetitle=qt") %>>
21
22
  <front>
22
23
  <%= vps.ele("title") -%>
23
24
 
@@ -702,6 +702,10 @@ COLORS
702
702
  checks = el.attr.delete("check")
703
703
  postprocs = el.attr.delete("post")
704
704
  case t
705
+ when "cbor"
706
+ warn "** There is no sourcecode-type “cbor”."
707
+ warn "** Do you mean “cbor-diag” (diagnostic notation)"
708
+ warn "** or “cbor-pretty” (annotated hex-dump)?"
705
709
  when "json"
706
710
  checks ||= "json"
707
711
  when /\A(.*)-from-yaml\z/
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.3
4
+ version: 1.7.5
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-11-23 00:00:00.000000000 Z
11
+ date: 2024-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown