kramdown-rfc2629 1.7.21 → 1.7.23
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-figures-tables +3 -0
- data/bin/kramdown-rfc-extract-sourcecode +46 -2
- data/data/kramdown-rfc2629.erb +6 -0
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/command.rb +6 -0
- data/lib/kramdown-rfc/kdrfc-processor.rb +13 -5
- data/lib/kramdown-rfc/yamlcheck.rb +44 -0
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 269381d3a05b02772eb68975943dcf119cd9010d9fdcfb4eb5df92886bfa59bb
|
4
|
+
data.tar.gz: 2f8c3f406037faaa02bd01f0eda40438a601ddaea49ff4c95ff8bcf168e0572a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 831fa5d0ea40f6f3e7c111160684eb818a6e4837159c2816c9d258c67258249226e5f895bfdb5b512f09af1c593a4176c378e99e395b180fd891409b06635206
|
7
|
+
data.tar.gz: f335e96c5bda06e7de555115ed3ae4057964287c24713082d23105ed9b93ddd0a63df6459887a9ae49fca3510fda4fc8fdcf880f588d1703ec2b422f9dc77cb9
|
@@ -68,10 +68,13 @@ lists.each do |k, v|
|
|
68
68
|
puts
|
69
69
|
puts "# #{title}"
|
70
70
|
puts "{:unnumbered}"
|
71
|
+
puts
|
72
|
+
puts "{:compact}"
|
71
73
|
else
|
72
74
|
fail
|
73
75
|
end
|
74
76
|
v.each_with_index do |(ref, ti), n|
|
77
|
+
ti.sub!(/,?[\p{Zl}\p{Zp}\p{Cc}].*/, "") # first line of caption only
|
75
78
|
ti = "[#{ti}](##{ref})" if ref
|
76
79
|
puts "#{n+1}. #{ti}"
|
77
80
|
end
|
@@ -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/data/kramdown-rfc2629.erb
CHANGED
@@ -52,6 +52,12 @@
|
|
52
52
|
<% end -%>
|
53
53
|
|
54
54
|
<rfc <%=rfcattrs%>>
|
55
|
+
<% ps.arr("v3xml2rfc", false) do |pi, val|
|
56
|
+
Array(val).each do |el|
|
57
|
+
-%>
|
58
|
+
<?v3xml2rfc <%=pi%>="<%=ps.escattr(el)%>"?>
|
59
|
+
<% end
|
60
|
+
end -%>
|
55
61
|
<front>
|
56
62
|
<%= ps.ele("title", ps.attr("abbrev=titleabbrev")) %>
|
57
63
|
|
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.23'
|
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]
|
@@ -18,6 +18,7 @@ class KDRFC
|
|
18
18
|
# )))
|
19
19
|
|
20
20
|
KDRFC_PREPEND = [ENV["KDRFC_PREPEND"]].compact
|
21
|
+
KDRFC_XML2RFC_FLAGS = Array(ENV["KDRFC_XML2RFC_FLAGS"]&.split(","))
|
21
22
|
|
22
23
|
def v3_flag?
|
23
24
|
[*(@options.v3 ? ["--v3"] : []),
|
@@ -37,6 +38,15 @@ def process_mkd(input, output)
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
def filename_ct(fn, ext)
|
42
|
+
bn = File.basename(fn, ".*")
|
43
|
+
if r = ENV["KRAMDOWN_RFC_DOCREV"]
|
44
|
+
bn << "-#{r}"
|
45
|
+
end
|
46
|
+
{filename: "#{bn}.#{ext}",
|
47
|
+
content_type: "text/plain"}
|
48
|
+
end
|
49
|
+
|
40
50
|
def run_idnits(*args)
|
41
51
|
if @options.remote
|
42
52
|
run_idnits_remotely(*args)
|
@@ -62,8 +72,7 @@ def run_idnits_remotely(txt_fn)
|
|
62
72
|
url = URI(IDNITS_WEBSERVICE)
|
63
73
|
req = Net::HTTP::Post.new(url)
|
64
74
|
form = [["file", File.open(txt_fn),
|
65
|
-
|
66
|
-
content_type: "text/plain"}],
|
75
|
+
filename_ct(txt_fn, "txt")],
|
67
76
|
["hidetext", "true"]]
|
68
77
|
diag = ["url/form: ", url, form].inspect
|
69
78
|
req.set_form(form, 'multipart/form-data')
|
@@ -105,7 +114,7 @@ end
|
|
105
114
|
def process_xml_locally(input, output, *flags)
|
106
115
|
warn "* converting locally from xml #{input} to txt #{output}" if @options.verbose
|
107
116
|
begin
|
108
|
-
o, s = Open3.capture2(*KDRFC_PREPEND, "xml2rfc", *v3_flag?, *flags, input)
|
117
|
+
o, s = Open3.capture2(*KDRFC_PREPEND, "xml2rfc", *v3_flag?, *flags, *KDRFC_XML2RFC_FLAGS, input)
|
109
118
|
puts o
|
110
119
|
if s.success?
|
111
120
|
warn "* #{output} written" if @options.verbose
|
@@ -152,8 +161,7 @@ def process_xml_remotely(input, output, *flags)
|
|
152
161
|
url = URI(XML2RFC_WEBSERVICE + maf)
|
153
162
|
req = Net::HTTP::Post.new(url)
|
154
163
|
form = [["file", File.open(input),
|
155
|
-
|
156
|
-
content_type: "text/plain"}]]
|
164
|
+
filename_ct(input, "xml")]]
|
157
165
|
diag = ["url/form: ", url, form].inspect
|
158
166
|
req.set_form(form, 'multipart/form-data')
|
159
167
|
warn "* requesting at #{url}" if @options.verbose
|
@@ -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
|
metadata
CHANGED
@@ -1,14 +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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-31 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: kramdown
|
@@ -204,12 +203,12 @@ files:
|
|
204
203
|
- lib/kramdown-rfc/rexml-formatters-conservative.rb
|
205
204
|
- lib/kramdown-rfc/rfc8792.rb
|
206
205
|
- lib/kramdown-rfc/svg-id-cleanup.rb
|
206
|
+
- lib/kramdown-rfc/yamlcheck.rb
|
207
207
|
- lib/kramdown-rfc2629.rb
|
208
208
|
homepage: http://github.com/cabo/kramdown-rfc
|
209
209
|
licenses:
|
210
210
|
- MIT
|
211
211
|
metadata: {}
|
212
|
-
post_install_message:
|
213
212
|
rdoc_options: []
|
214
213
|
require_paths:
|
215
214
|
- lib
|
@@ -224,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
223
|
- !ruby/object:Gem::Version
|
225
224
|
version: '0'
|
226
225
|
requirements: []
|
227
|
-
rubygems_version: 3.
|
228
|
-
signing_key:
|
226
|
+
rubygems_version: 3.6.2
|
229
227
|
specification_version: 4
|
230
228
|
summary: Kramdown extension for generating RFCXML (RFC 799x).
|
231
229
|
test_files: []
|