kramdown-rfc2629 1.7.22 → 1.7.24
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 +4 -4
- data/bin/kramdown-rfc-extract-sourcecode +46 -2
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/command.rb +6 -0
- data/lib/kramdown-rfc/yamlcheck.rb +44 -0
- data/lib/kramdown-rfc2629.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 213633771643a6c36faef7204ecc4071901838d6653c56717845c5f3df54fb2d
|
4
|
+
data.tar.gz: b560600b6d5579180a2f5b282a9650a1190ea33480da427c90790425d0627cc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc780509d1146a740d76d366e8359bd4134b25fbeffdd5f4caab3d0e9f53f04c48aa9d06eefd17678661c7ab3c146a8ab3a89cb05e0be932c3657933781c8821
|
7
|
+
data.tar.gz: 9a1afcbd4bdde8e1e9f0145f3f35a5c6f7e6985a5fa4bb4b0d1ba92d48b7b29166fac98499fb0aee53f61b01fe54285aa8382930176cfe8b8d871e4d16b8c019
|
@@ -40,6 +40,7 @@ end
|
|
40
40
|
|
41
41
|
target = nil
|
42
42
|
dir = nil
|
43
|
+
out_type = out_name = nil
|
43
44
|
unfold = true
|
44
45
|
targets = [:list, :files, :zip, :yaml]
|
45
46
|
require 'optparse'
|
@@ -52,6 +53,10 @@ begin
|
|
52
53
|
opts.on("-dDIR", "--dir=DIR", "Target directory (default: sourcecode)") do |v|
|
53
54
|
dir = v
|
54
55
|
end
|
56
|
+
opts.on("-xTYPE/NAME", "--extract=TYPE/NAME", "Extract single item to stdout") do |v|
|
57
|
+
target = :stdout
|
58
|
+
out_type, out_name = v.split("/", 2)
|
59
|
+
end
|
55
60
|
opts.on("-f", "--[no-]unfold", "RFC8792-unfold (default: yes)") do |v|
|
56
61
|
unfold = v
|
57
62
|
end
|
@@ -74,8 +79,26 @@ target ||= :list
|
|
74
79
|
gensym = "unnamed-000"
|
75
80
|
taken = Hash.new { |h, k| h[k] = Hash.new }
|
76
81
|
warned = Hash.new { |h, k| h[k] = Hash.new }
|
77
|
-
|
78
|
-
|
82
|
+
filenames = ARGV.inspect
|
83
|
+
begin
|
84
|
+
d = REXML::Document.new(ARGF)
|
85
|
+
dr = d.root
|
86
|
+
unless dr
|
87
|
+
warn "*** Can't parse: #{filenames}"
|
88
|
+
exit(1)
|
89
|
+
end
|
90
|
+
rescue Errno::ENOENT
|
91
|
+
warn "*** Not found: #{filenames}"
|
92
|
+
exit(1)
|
93
|
+
rescue => e
|
94
|
+
begin
|
95
|
+
warn "*** Can't parse: #{filenames} (#{e.to_s[0..120]})"
|
96
|
+
rescue => e
|
97
|
+
warn "*** Can't parse: #{filenames} (#{e.to_s[0..120]})"
|
98
|
+
end
|
99
|
+
exit(1)
|
100
|
+
end
|
101
|
+
REXML::XPath.each(dr, "//sourcecode|//artwork") do |x|
|
79
102
|
if ty = x[:type]
|
80
103
|
is_svg = false
|
81
104
|
REXML::XPath.each(x, "svg") do is_svg = true end
|
@@ -161,6 +184,27 @@ def make_directory_from(dir, taken)
|
|
161
184
|
end
|
162
185
|
|
163
186
|
case target
|
187
|
+
when :stdout
|
188
|
+
if dataset = taken[out_type]
|
189
|
+
unless out_name
|
190
|
+
case dataset.size
|
191
|
+
when 0
|
192
|
+
warn "No sourcecodes under #{out_type}"
|
193
|
+
exit(1)
|
194
|
+
when 1
|
195
|
+
out_name ||= dataset.keys.first
|
196
|
+
else
|
197
|
+
warn "Multiple sourcecodes under #{out_type}: #{dataset.keys}"
|
198
|
+
exit(1)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
if data = dataset[out_name]
|
202
|
+
puts data
|
203
|
+
exit
|
204
|
+
end
|
205
|
+
end
|
206
|
+
warn "*** Cannot find sourcecode #{out_type}/#{out_name}"
|
207
|
+
exit(1)
|
164
208
|
when :yaml
|
165
209
|
puts taken.to_yaml
|
166
210
|
when :list
|
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.24'
|
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-rfc/command.rb
CHANGED
@@ -289,6 +289,12 @@ def xml_from_sections(input)
|
|
289
289
|
# the first section is a YAML with front matter parameters (don't put a label here)
|
290
290
|
# We put back the "---" plus gratuitous blank lines to hack the line number in errors
|
291
291
|
yaml_in = input[/---\s*/] << sections.shift[2]
|
292
|
+
begin
|
293
|
+
require 'kramdown-rfc/yamlcheck'
|
294
|
+
KramdownRFC::YAMLcheck.check_dup_keys(yaml_in)
|
295
|
+
rescue => e
|
296
|
+
warn "** Cannot check for duplicate keys in YAML header (#{e})"
|
297
|
+
end
|
292
298
|
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
|
293
299
|
|
294
300
|
if v = ps[:v]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module KramdownRFC
|
4
|
+
module YAMLcheck
|
5
|
+
|
6
|
+
def self.short_name(node)
|
7
|
+
if node.scalar?
|
8
|
+
node.value
|
9
|
+
else
|
10
|
+
node.children&.map {short_name(_1)}&.join("_")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Does not follow aliases.
|
15
|
+
def self.check_dup_keys1(node, path)
|
16
|
+
if YAML::Nodes::Mapping === node
|
17
|
+
children = node.children.each_slice(2)
|
18
|
+
duplicates = children.map { |key_node, _value_node|
|
19
|
+
key_node }.group_by{short_name(_1)}.select { |_value, nodes| nodes.size > 1 }
|
20
|
+
|
21
|
+
duplicates.each do |key, nodes|
|
22
|
+
name = (path + [key]).join("/")
|
23
|
+
lines = nodes.map { |occurrence| occurrence.start_line + 1 }.join(", ")
|
24
|
+
warn "** duplicate map key >#{name}< in YAML, lines #{lines}"
|
25
|
+
end
|
26
|
+
|
27
|
+
children.each do |key_node, value_node|
|
28
|
+
newname = short_name(key_node)
|
29
|
+
check_dup_keys1(value_node, path + Array(newname))
|
30
|
+
end
|
31
|
+
else
|
32
|
+
node.children.to_a.each { |child| check_dup_keys1(child, path) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.check_dup_keys(data)
|
37
|
+
ast = YAML.parse_stream(data)
|
38
|
+
check_dup_keys1(ast, [])
|
39
|
+
end
|
40
|
+
|
41
|
+
# check_dup_keys(DATA)
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -1203,6 +1203,7 @@ COLORS
|
|
1203
1203
|
|
1204
1204
|
KRAMDOWN_OFFLINE = ENV["KRAMDOWN_OFFLINE"]
|
1205
1205
|
KRAMDOWN_REFCACHE_REFETCH = ENV["KRAMDOWN_REFCACHE_REFETCH"]
|
1206
|
+
KRAMDOWN_REFCACHE_QUIET = ENV["KRAMDOWN_REFCACHE_QUIET"]
|
1206
1207
|
|
1207
1208
|
def get_and_write_resource(url, fn)
|
1208
1209
|
options = {}
|
@@ -1251,7 +1252,7 @@ COLORS
|
|
1251
1252
|
message = "fetching"
|
1252
1253
|
fetch_timeout = 60 # seconds; long timeout needed for Travis
|
1253
1254
|
end
|
1254
|
-
$stderr.puts "#{fn}: #{message} from #{url}"
|
1255
|
+
$stderr.puts "#{fn}: #{message} from #{url}" unless KRAMDOWN_REFCACHE_QUIET
|
1255
1256
|
if Array === url
|
1256
1257
|
begin
|
1257
1258
|
case url[0]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: kramdown
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/kramdown-rfc/rexml-formatters-conservative.rb
|
204
204
|
- lib/kramdown-rfc/rfc8792.rb
|
205
205
|
- lib/kramdown-rfc/svg-id-cleanup.rb
|
206
|
+
- lib/kramdown-rfc/yamlcheck.rb
|
206
207
|
- lib/kramdown-rfc2629.rb
|
207
208
|
homepage: http://github.com/cabo/kramdown-rfc
|
208
209
|
licenses:
|