kramdown-rfc2629 1.7.3 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kramdown-rfc-extract-sourcecode +68 -6
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c60909608ac8c84853d39c03fdf0da2cdfd179601a63a5b07a52099925a8ce9
|
4
|
+
data.tar.gz: ce8fcfe62f77fc23a8a5514e329ade31864ac099f5a45c6bbce976e3a8210a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b11fe08773c3e5c80aaaaeff16bf6728ab8656ee95ce0186bf786b2da2b99832b65b36fa32e7801e36b3f9c32b4e90830fa4c14f5136d0f7945c2c342ba17d1
|
7
|
+
data.tar.gz: 35a372c29219550c56a2335a497b3117621ac7b998792d596272fad84725a6f464a89bb931c9472a0ef4320eee40b69088e3f595ef8e6a028e7ba0a57e58436f
|
@@ -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 =
|
59
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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] = ''
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.7.
|
3
|
+
s.version = '1.7.4'
|
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.}
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -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.
|
4
|
+
version: 1.7.4
|
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
|
+
date: 2023-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|