kramdown-rfc2629 1.6.24 → 1.6.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/bin/echars +28 -6
- data/bin/kdrfc +1 -1
- data/kramdown-rfc2629.gemspec +4 -1
- data/lib/kramdown-rfc/command.rb +1 -1
- data/lib/kramdown-rfc/kdrfc-processor.rb +54 -24
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd317f54435256ae6bf63de8753a3f544b63caa1922cadf008f550f242071a48
|
4
|
+
data.tar.gz: f5c44616bf9debf61856c692c61125da531d966e8f33331fce936ea6efbac6fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f895cbca96c9bccca39afb5fbd83b6815ecfcb1a43b9287f7a1bb28de4cc765543cc8f2e9b62564bb71c03efc7651d70b5a5ad68f913888d0657ee8605244546
|
7
|
+
data.tar.gz: a73cb2f7a94d14e7d08593ff2562f9f1cd52aaab969ccf025af66452ebae22ff8a7cb8c52551c1fde43ac5604011c1363ab501ce251a0094264bcadbb3798c55
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ To use kramdown-rfc, you'll need Ruby (at least version 2.3, but
|
|
33
33
|
preferably a current version), and maybe
|
34
34
|
[XML2RFC][] if you want to see the fruits of your work.
|
35
35
|
|
36
|
-
kramdown-rfc mydraft.
|
36
|
+
kramdown-rfc mydraft.md >mydraft.xml
|
37
37
|
xml2rfc mydraft.xml
|
38
38
|
|
39
39
|
(The most popular file name extension that IETF people have for
|
@@ -43,11 +43,11 @@ descriptions here, any extension such as .mkd will do, too.)
|
|
43
43
|
A more brief interface for both calling kramdown-rfc and XML2RFC
|
44
44
|
is provided by `kdrfc`:
|
45
45
|
|
46
|
-
kdrfc mydraft.
|
46
|
+
kdrfc mydraft.md
|
47
47
|
|
48
48
|
`kdrfc` can also use a remote installation of XML2RFC if needed:
|
49
49
|
|
50
|
-
kdrfc -r mydraft.
|
50
|
+
kdrfc -r mydraft.md
|
51
51
|
|
52
52
|
# Versions of RFCXML
|
53
53
|
|
data/bin/echars
CHANGED
@@ -1,17 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'unicode/name'
|
3
|
+
require 'unicode/scripts'
|
4
|
+
require 'unicode/blocks'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
def readable(c)
|
8
|
+
j = c.to_json
|
9
|
+
if j.size == 3
|
10
|
+
j[1...-1]
|
11
|
+
else
|
12
|
+
j
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
3
16
|
hist = Hash.new(0)
|
4
17
|
ARGF.read.each_char do |c|
|
5
18
|
hist[c] += 1 unless c.ord.between?(32, 126)
|
6
19
|
end
|
7
20
|
hist.delete("\n")
|
8
|
-
|
9
|
-
|
10
|
-
|
21
|
+
hist.keys.sort.group_by {|c| Unicode::Blocks.block(c)}.each do |block, l|
|
22
|
+
scripts = Set[]
|
23
|
+
l.each do |c|
|
24
|
+
scripts << Unicode::Scripts.scripts(c)
|
25
|
+
end
|
26
|
+
if scripts.size == 1
|
27
|
+
puts "*** #{block} (#{scripts.join})"
|
28
|
+
else
|
29
|
+
puts "*** #{block}"
|
30
|
+
end
|
11
31
|
l.each do |c|
|
12
|
-
|
32
|
+
s = "#{readable(c)}: U+#{"%04X %4d" % [c.ord, hist[c]]
|
13
33
|
} #{Unicode::Name.correct(c) ||
|
14
|
-
Unicode::Name.label(c)
|
34
|
+
Unicode::Name.label(c)
|
35
|
+
}"
|
36
|
+
s << " (#{Unicode::Scripts.scripts(c).join(", ")})" if scripts.size != 1
|
37
|
+
puts s
|
15
38
|
end
|
16
|
-
cl = "*** Non-Latin"
|
17
39
|
end
|
data/bin/kdrfc
CHANGED
@@ -10,7 +10,7 @@ kdrfc.options.txt = true # default
|
|
10
10
|
|
11
11
|
op = OptionParser.new do |opts|
|
12
12
|
opts.banner = <<BANNER
|
13
|
-
Usage: kdrfc [options] file.md|file.
|
13
|
+
Usage: kdrfc [options] file.md|file.xml
|
14
14
|
Version: #{KDRFC_VERSION}
|
15
15
|
BANNER
|
16
16
|
opts.on("-V", "--version", "Show version and exit") do |v|
|
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.6.
|
3
|
+
s.version = '1.6.26'
|
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.}
|
@@ -9,6 +9,9 @@ spec = Gem::Specification.new do |s|
|
|
9
9
|
s.add_dependency('certified', '~> 1.0')
|
10
10
|
s.add_dependency('json_pure', '~> 2.0')
|
11
11
|
s.add_dependency('unicode-name', '~> 1.0')
|
12
|
+
s.add_dependency('unicode-blocks', '~> 1.0')
|
13
|
+
s.add_dependency('unicode-scripts', '~> 1.0')
|
14
|
+
s.add_dependency('net-http-persistent', '~> 4.0')
|
12
15
|
s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/echars bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/kramdown-rfc-autolink-iref-cleanup bin/de-gfm)
|
13
16
|
s.require_path = 'lib'
|
14
17
|
s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'echars',
|
data/lib/kramdown-rfc/command.rb
CHANGED
@@ -490,7 +490,7 @@ require 'ostruct'
|
|
490
490
|
$options ||= OpenStruct.new
|
491
491
|
op = OptionParser.new do |opts|
|
492
492
|
opts.banner = <<BANNER
|
493
|
-
Usage: kramdown-rfc2629 [options] file.md
|
493
|
+
Usage: kramdown-rfc2629 [options] [file.md] > file.xml
|
494
494
|
Version: #{KDRFC_VERSION}
|
495
495
|
BANNER
|
496
496
|
opts.on("-V", "--version", "Show version and exit") do |v|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'net/http'
|
3
|
+
require 'net/http/persistent'
|
3
4
|
require 'open3'
|
4
5
|
require 'ostruct'
|
6
|
+
require 'json'
|
5
7
|
|
6
8
|
module KramdownRFC
|
7
9
|
|
@@ -65,50 +67,78 @@ def process_xml_locally(input, output, *flags)
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
70
|
+
# curl https://author-tools.ietf.org/api/render/text -X POST -F "file=@..."
|
68
71
|
XML2RFC_WEBSERVICE = ENV["KRAMDOWN_XML2RFC_WEBSERVICE"] ||
|
69
|
-
'
|
72
|
+
'https://author-tools.ietf.org/api/render/'
|
70
73
|
|
71
74
|
MODE_AS_FORMAT = {
|
72
|
-
|
73
|
-
"--
|
74
|
-
"--
|
75
|
-
|
76
|
-
true => { # v3
|
77
|
-
"--text" => "txt/v3ascii",
|
78
|
-
"--html" => "html/v3ascii",
|
79
|
-
"--v2v3" => "v3xml/ascii",
|
80
|
-
}
|
75
|
+
"--text" => "text",
|
76
|
+
"--html" => "html",
|
77
|
+
"--v2v3" => "xml",
|
78
|
+
"--pdf" => "pdf",
|
81
79
|
}
|
82
80
|
|
83
|
-
|
81
|
+
def checked_json(t)
|
82
|
+
begin
|
83
|
+
JSON.load(t)
|
84
|
+
rescue => e
|
85
|
+
raise IOError.new("*** JSON result: #{e.detailed_message}, #{diag}")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def persistent_http
|
90
|
+
$http ||= Net::HTTP::Persistent.new name: 'kramdown-rfc'
|
91
|
+
end
|
92
|
+
|
84
93
|
def process_xml_remotely(input, output, *flags)
|
85
|
-
|
94
|
+
|
86
95
|
format = flags[0] || "--text"
|
87
|
-
#
|
88
|
-
maf = MODE_AS_FORMAT[
|
96
|
+
warn "* converting remotely from xml #{input} to #{format} #{output}" if @options.verbose
|
97
|
+
maf = MODE_AS_FORMAT[format]
|
89
98
|
unless maf
|
90
|
-
raise ArgumentError.new("*** don't know how to convert remotely from xml #{input} to
|
99
|
+
raise ArgumentError.new("*** don't know how to convert remotely from xml #{input} to #{format} #{output}")
|
91
100
|
end
|
92
|
-
url = URI(XML2RFC_WEBSERVICE)
|
101
|
+
url = URI(XML2RFC_WEBSERVICE + maf)
|
93
102
|
req = Net::HTTP::Post.new(url)
|
94
|
-
form = [["
|
95
|
-
["type", "binary"],
|
96
|
-
["input", File.open(input),
|
103
|
+
form = [["file", File.open(input),
|
97
104
|
{filename: "input.xml",
|
98
105
|
content_type: "text/plain"}]]
|
99
106
|
diag = ["url/form: ", url, form].inspect
|
100
107
|
req.set_form(form, 'multipart/form-data')
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
}
|
108
|
+
warn "* requesting at #{url}" if @options.verbose
|
109
|
+
t0 = Time.now
|
110
|
+
res = persistent_http.request(url, req)
|
111
|
+
warn "* elapsed time: #{Time.now - t0}" if @options.verbose
|
105
112
|
case res
|
113
|
+
when Net::HTTPBadRequest
|
114
|
+
result = checked_json(res.body)
|
115
|
+
raise IOError.new("*** Remote Error: #{result["error"]}")
|
106
116
|
when Net::HTTPOK
|
107
117
|
case res.content_type
|
108
|
-
when 'application/
|
118
|
+
when 'application/json'
|
109
119
|
if res.body == ''
|
110
120
|
raise IOError.new("*** HTTP response is empty with status #{res.code}, not written")
|
111
121
|
end
|
122
|
+
# warn "* res.body #{res.body}" if @options.verbose
|
123
|
+
result = checked_json(res.body)
|
124
|
+
if logs = result["logs"]
|
125
|
+
if errors = logs["errors"]
|
126
|
+
errors.each do |err|
|
127
|
+
warn("*** Error: #{err}")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
if warnings = logs["warnings"]
|
131
|
+
warnings.each do |w|
|
132
|
+
warn("** Warning: #{w}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
raise IOError.new("*** No useful result from remote") unless result["url"]
|
137
|
+
res = persistent_http.request(URI(result["url"]))
|
138
|
+
warn "* result content type #{res.content_type}" if @options.verbose
|
139
|
+
if res.body == ''
|
140
|
+
raise IOError.new("*** Second HTTP response is empty with status #{res.code}, not written")
|
141
|
+
end
|
112
142
|
File.open(output, "w") do |fo|
|
113
143
|
fo.print(res.body)
|
114
144
|
end
|
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.6.
|
4
|
+
version: 1.6.26
|
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-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -80,6 +80,48 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: unicode-blocks
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: unicode-scripts
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: net-http-persistent
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.0'
|
83
125
|
description: |-
|
84
126
|
An RFCXML (RFC 799x) generating backend for Thomas Leitner's
|
85
127
|
"kramdown" markdown parser. Mostly useful for RFC writers.
|
@@ -143,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
185
|
- !ruby/object:Gem::Version
|
144
186
|
version: '0'
|
145
187
|
requirements: []
|
146
|
-
rubygems_version: 3.4.
|
188
|
+
rubygems_version: 3.4.6
|
147
189
|
signing_key:
|
148
190
|
specification_version: 4
|
149
191
|
summary: Kramdown extension for generating RFCXML (RFC 799x).
|