kramdown-rfc2629 1.6.23 → 1.6.25
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/kdrfc +1 -1
- data/kramdown-rfc2629.gemspec +2 -1
- data/lib/kramdown-rfc/command.rb +1 -1
- data/lib/kramdown-rfc/kdrfc-processor.rb +54 -24
- data/lib/kramdown-rfc2629.rb +5 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3977e2f9efc48b95ff26f4559ac3442b2a66276d73def5ef190fac81e66c702b
|
4
|
+
data.tar.gz: 3d5a0bbe14f3457763cd0172d6912b32ab6ccec70e3c8106a58173587fd57b61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c085a74725465ff0cee2d1dc09af85e642b49528d45ba16be323b368c1e9106d27f2c7fbbe3ede62e5de284974d1740d273dec69e288058540bfd3d8bdffb536
|
7
|
+
data.tar.gz: 19e8406e4c7accbd6c90308089a2dbb155167e2ed9cb7087c6b758c47ce097c902211d107eacff6dde08e429e2b4a3efba572327c2415c57f545a645edfe778a
|
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/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.25'
|
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,7 @@ 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('net-http-persistent', '~> 4.0')
|
12
13
|
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
14
|
s.require_path = 'lib'
|
14
15
|
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
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -560,7 +560,11 @@ COLORS
|
|
560
560
|
if result1
|
561
561
|
result1 = svg_clean(result1) unless dont_clean
|
562
562
|
unless dont_check
|
563
|
-
|
563
|
+
file = Tempfile.new("kramdown-rfc")
|
564
|
+
file.write(result1)
|
565
|
+
file.close
|
566
|
+
result1, err, _s = Open3.capture3("svgcheck -qa #{file.path}");
|
567
|
+
file.unlink
|
564
568
|
# warn ["svgcheck:", result1.inspect]
|
565
569
|
capture_croak("svgcheck", err)
|
566
570
|
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.25
|
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-02-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: net-http-persistent
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.0'
|
83
97
|
description: |-
|
84
98
|
An RFCXML (RFC 799x) generating backend for Thomas Leitner's
|
85
99
|
"kramdown" markdown parser. Mostly useful for RFC writers.
|