kramdown-rfc2629 1.4.19 → 1.5.4
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/kdrfc +18 -150
- data/data/kramdown-rfc2629.erb +11 -0
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/kdrfc-processor.rb +154 -0
- data/lib/kramdown-rfc/refxml.rb +21 -3
- data/lib/kramdown-rfc2629.rb +48 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49968f621678e46d7ecde1451347a63f8a9dd93d0c7dc1f822ee7314f1c7c3fc
|
4
|
+
data.tar.gz: d94a74186a8be6c9880c8e15d73b7961df19ab566a55b5a3a643a34aaa1f3c5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 424d084703c00e29cad08da0ee6f4568ac6861772eef79fadf26c6f39a4747d6ec192f04abf262d3f26579d4e7fb8493d00c34f9cf01183cabec1b3ccbe1bf4a
|
7
|
+
data.tar.gz: f5d6cf7487ce6601bf2cb3198c9d12727d5c4cc0752c5c9b11f6f29a43304874dca36653e047812486888889bc07e0999fad89d3847b0cb1122f0c020f9f33a1
|
data/bin/kdrfc
CHANGED
@@ -1,127 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby -KU
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require 'open3'
|
2
|
+
require 'kramdown-rfc/kdrfc-processor'
|
3
|
+
require 'optparse'
|
5
4
|
|
6
5
|
# try to get this from gemspec.
|
7
6
|
KDRFC_VERSION=Gem.loaded_specs["kramdown-rfc2629"].version rescue "unknown-version"
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
def v3_flag?
|
12
|
-
$options.v3 ? ["--v3"] : []
|
13
|
-
end
|
14
|
-
|
15
|
-
def process_mkd(input, output)
|
16
|
-
warn "* converting locally from markdown #{input} to xml #{output}" if $options.verbose
|
17
|
-
o, s = Open3.capture2(*KDRFC_PREPEND, "kramdown-rfc2629", *v3_flag?, input)
|
18
|
-
if s.success?
|
19
|
-
File.open(output, "w") do |fo|
|
20
|
-
fo.print(o)
|
21
|
-
end
|
22
|
-
warn "* #{output} written" if $options.verbose
|
23
|
-
else
|
24
|
-
warn "*** kramdown-rfc failed, status #{s.exitstatus}"
|
25
|
-
exit 1
|
26
|
-
end
|
27
|
-
end
|
8
|
+
kdrfc = KramdownRFC::KDRFC.new
|
9
|
+
kdrfc.options.txt = true # default
|
28
10
|
|
29
|
-
def run_idnits(txt_fn)
|
30
|
-
unless system("idnits", txt_fn)
|
31
|
-
warn "*** problem #$? running idnits"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def process_xml(*args)
|
36
|
-
if $options.remote
|
37
|
-
process_xml_remotely(*args)
|
38
|
-
else
|
39
|
-
process_xml_locally(*args)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def process_xml_locally(input, output, *flags)
|
44
|
-
warn "* converting locally from xml #{input} to txt #{output}" if $options.verbose
|
45
|
-
begin
|
46
|
-
o, s = Open3.capture2(*KDRFC_PREPEND, "xml2rfc", *v3_flag?, *flags, input)
|
47
|
-
puts o
|
48
|
-
if s.success?
|
49
|
-
warn "* #{output} written" if $options.verbose
|
50
|
-
else
|
51
|
-
warn "*** xml2rfc failed, status #{s.exitstatus} (possibly try with -r)"
|
52
|
-
exit 1
|
53
|
-
end
|
54
|
-
rescue Errno::ENOENT
|
55
|
-
warn "*** falling back to remote processing" if $options.verbose
|
56
|
-
process_xml_remotely(input, output, *flags)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
XML2RFC_WEBSERVICE = ENV["KRAMDOWN_XML2RFC_WEBSERVICE"] ||
|
61
|
-
'http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc-dev.cgi'
|
62
|
-
|
63
|
-
MODE_AS_FORMAT = {
|
64
|
-
nil => { # v2
|
65
|
-
"--text" => "txt/ascii",
|
66
|
-
"--html" => "html/ascii",
|
67
|
-
},
|
68
|
-
true => { # v3
|
69
|
-
"--text" => "txt/v3ascii",
|
70
|
-
"--html" => "html/v3ascii",
|
71
|
-
"--v2v3" => "v3xml/ascii",
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
def process_xml_remotely(input, output, *flags)
|
76
|
-
warn "* converting remotely from xml #{input} to txt #{output}" if $options.verbose
|
77
|
-
format = flags[0] || "--text"
|
78
|
-
# warn [:V3, $options.v3].inspect
|
79
|
-
maf = MODE_AS_FORMAT[$options.v3][format]
|
80
|
-
unless maf
|
81
|
-
warn "*** don't know how to convert remotely from xml #{input} to txt #{output}"
|
82
|
-
exit(1)
|
83
|
-
end
|
84
|
-
url = URI(XML2RFC_WEBSERVICE)
|
85
|
-
req = Net::HTTP::Post.new(url)
|
86
|
-
form = [["modeAsFormat", maf],
|
87
|
-
["type", "binary"],
|
88
|
-
["input", File.open(input),
|
89
|
-
{filename: "input.xml",
|
90
|
-
content_type: "text/plain"}]]
|
91
|
-
diag = ["url/form: ", url, form].inspect
|
92
|
-
req.set_form(form, 'multipart/form-data')
|
93
|
-
res = Net::HTTP::start(url.hostname, url.port,
|
94
|
-
:use_ssl => url.scheme == 'https' ) {|http|
|
95
|
-
http.request(req)
|
96
|
-
}
|
97
|
-
case res
|
98
|
-
when Net::HTTPOK
|
99
|
-
case res.content_type
|
100
|
-
when 'application/octet-stream'
|
101
|
-
if res.body == ''
|
102
|
-
warn "*** HTTP response is empty with status #{res.code}, not written"
|
103
|
-
exit 1
|
104
|
-
end
|
105
|
-
File.open(output, "w") do |fo|
|
106
|
-
fo.print(res.body)
|
107
|
-
end
|
108
|
-
warn "* #{output} written" if $options.verbose
|
109
|
-
else
|
110
|
-
warn "*** HTTP response has unexpected content_type #{res.content_type} with status #{res.code}, #{diag}"
|
111
|
-
warn res.body
|
112
|
-
exit 1
|
113
|
-
end
|
114
|
-
else
|
115
|
-
warn "*** HTTP response: #{res.code}, #{diag}"
|
116
|
-
exit 1
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
require 'optparse'
|
121
|
-
require 'ostruct'
|
122
|
-
|
123
|
-
$options = OpenStruct.new
|
124
|
-
$options.txt = true # default
|
125
11
|
op = OptionParser.new do |opts|
|
126
12
|
opts.banner = <<BANNER
|
127
13
|
Usage: kdrfc [options] file.md|file.mkd|file.xml
|
@@ -136,63 +22,45 @@ BANNER
|
|
136
22
|
exit
|
137
23
|
end
|
138
24
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
139
|
-
|
25
|
+
kdrfc.options.verbose = v
|
140
26
|
end
|
141
27
|
opts.on("-r", "--[no-]remote", "Run xml2rfc remotely even if there is a local one") do |v|
|
142
|
-
|
28
|
+
kdrfc.options.remote = v
|
143
29
|
end
|
144
30
|
opts.on("-x", "--[no-]xml", "Convert to xml only") do |v|
|
145
|
-
|
31
|
+
kdrfc.options.xml_only = v
|
146
32
|
end
|
147
33
|
opts.on("-p", "--[no-]prep", "Convert xml to prepped xml") do |v|
|
148
|
-
|
34
|
+
kdrfc.options.prep = v
|
149
35
|
end
|
150
36
|
opts.on("-P", "-f", "--[no-]pdf", "Convert xml to PDF") do |v|
|
151
|
-
|
37
|
+
kdrfc.options.pdf = v
|
152
38
|
end
|
153
39
|
opts.on("-c", "--[no-]convert", "Convert xml to v3 xml") do |v|
|
154
|
-
|
40
|
+
kdrfc.options.v2v3 = v
|
155
41
|
end
|
156
42
|
opts.on("-i", "--[no-]idnits", "Run idnits on the resulting text") do |v|
|
157
|
-
|
43
|
+
kdrfc.options.idnits = v
|
158
44
|
end
|
159
45
|
opts.on("-h", "--[no-]html", "Convert to html as well") do |v|
|
160
|
-
|
46
|
+
kdrfc.options.html = v
|
161
47
|
end
|
162
48
|
opts.on("-t", "--[no-]txt", "Convert to txt as well") do |v|
|
163
|
-
|
49
|
+
kdrfc.options.txt = v
|
164
50
|
end
|
165
51
|
opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
|
166
|
-
|
52
|
+
kdrfc.options.v3 = v
|
167
53
|
end
|
168
54
|
end
|
169
55
|
op.parse!
|
170
56
|
|
171
|
-
def process_the_xml(fn, base)
|
172
|
-
process_xml(fn, "#{base}.prepped.xml", "--preptool") if $options.prep
|
173
|
-
process_xml(fn, "#{base}.v2v3.xml", "--v2v3") if $options.v2v3
|
174
|
-
process_xml(fn, "#{base}.txt") if $options.txt || $options.idnits
|
175
|
-
process_xml(fn, "#{base}.html", "--html") if $options.html
|
176
|
-
process_xml(fn, "#{base}.pdf", "--pdf") if $options.pdf
|
177
|
-
run_idnits("#{base}.txt") if $options.idnits
|
178
|
-
end
|
179
|
-
|
180
57
|
case ARGV.size
|
181
58
|
when 1
|
182
59
|
fn = ARGV[0]
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
else # FIXME: copy/paste
|
188
|
-
process_the_xml(fn, $1)
|
189
|
-
end
|
190
|
-
when /(.*)\.mk?d\z/
|
191
|
-
xml = "#$1.xml"
|
192
|
-
process_mkd(fn, xml)
|
193
|
-
process_the_xml(xml, $1) unless $options.xml_only
|
194
|
-
else
|
195
|
-
warn "Unknown file type: #{fn}"
|
60
|
+
begin
|
61
|
+
kdrfc.process(fn)
|
62
|
+
rescue StandardError => e
|
63
|
+
warn e.to_s
|
196
64
|
exit 1
|
197
65
|
end
|
198
66
|
else
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -69,6 +69,17 @@
|
|
69
69
|
|
70
70
|
<middle>
|
71
71
|
|
72
|
+
{:/nomarkdown}
|
73
|
+
{:quote: gi="blockquote"}
|
74
|
+
{:aside: gi="aside"}
|
75
|
+
{:markers: sourcecode-markers="true"}
|
76
|
+
{:unnumbered: numbered="false"}
|
77
|
+
{:vspace: vspace="0"}
|
78
|
+
{:removeinrfc: removeinrfc="true"}
|
79
|
+
{:notoc: toc="exclude"}
|
80
|
+
{:compact: spacing="compact"}
|
81
|
+
{::nomarkdown}
|
82
|
+
|
72
83
|
<%= sechash.delete("middle") %>
|
73
84
|
|
74
85
|
</middle>
|
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.4
|
3
|
+
s.version = '1.5.4'
|
4
4
|
s.summary = "Kramdown extension for generating RFC 7749 XML."
|
5
5
|
s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
|
6
6
|
"kramdown" markdown parser. Mostly useful for RFC writers.}
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'open3'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module KramdownRFC
|
7
|
+
|
8
|
+
class KDRFC
|
9
|
+
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@options = OpenStruct.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# )))
|
17
|
+
|
18
|
+
KDRFC_PREPEND = [ENV["KDRFC_PREPEND"]].compact
|
19
|
+
|
20
|
+
def v3_flag?
|
21
|
+
@options.v3 ? ["--v3"] : []
|
22
|
+
end
|
23
|
+
|
24
|
+
def process_mkd(input, output)
|
25
|
+
warn "* converting locally from markdown #{input} to xml #{output}" if @options.verbose
|
26
|
+
o, s = Open3.capture2(*KDRFC_PREPEND, "kramdown-rfc2629", *v3_flag?, input)
|
27
|
+
if s.success?
|
28
|
+
File.open(output, "w") do |fo|
|
29
|
+
fo.print(o)
|
30
|
+
end
|
31
|
+
warn "* #{output} written" if @options.verbose
|
32
|
+
else
|
33
|
+
raise IOError.new("*** kramdown-rfc failed, status #{s.exitstatus}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_idnits(txt_fn)
|
38
|
+
unless system("idnits", txt_fn)
|
39
|
+
warn "*** problem #$? running idnits"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def process_xml(*args)
|
44
|
+
if @options.remote
|
45
|
+
process_xml_remotely(*args)
|
46
|
+
else
|
47
|
+
process_xml_locally(*args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def process_xml_locally(input, output, *flags)
|
52
|
+
warn "* converting locally from xml #{input} to txt #{output}" if @options.verbose
|
53
|
+
begin
|
54
|
+
o, s = Open3.capture2(*KDRFC_PREPEND, "xml2rfc", *v3_flag?, *flags, input)
|
55
|
+
puts o
|
56
|
+
if s.success?
|
57
|
+
warn "* #{output} written" if @options.verbose
|
58
|
+
else
|
59
|
+
raise IOError.new("*** xml2rfc failed, status #{s.exitstatus} (possibly try with -r)")
|
60
|
+
end
|
61
|
+
rescue Errno::ENOENT
|
62
|
+
warn "*** falling back to remote xml2rfc processing (web service)" # if @options.verbose
|
63
|
+
process_xml_remotely(input, output, *flags)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
XML2RFC_WEBSERVICE = ENV["KRAMDOWN_XML2RFC_WEBSERVICE"] ||
|
68
|
+
'http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc-dev.cgi'
|
69
|
+
|
70
|
+
MODE_AS_FORMAT = {
|
71
|
+
nil => { # v2
|
72
|
+
"--text" => "txt/ascii",
|
73
|
+
"--html" => "html/ascii",
|
74
|
+
},
|
75
|
+
true => { # v3
|
76
|
+
"--text" => "txt/v3ascii",
|
77
|
+
"--html" => "html/v3ascii",
|
78
|
+
"--v2v3" => "v3xml/ascii",
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
def process_xml_remotely(input, output, *flags)
|
83
|
+
warn "* converting remotely from xml #{input} to txt #{output}" if @options.verbose
|
84
|
+
format = flags[0] || "--text"
|
85
|
+
# warn [:V3, @options.v3].inspect
|
86
|
+
maf = MODE_AS_FORMAT[@options.v3][format]
|
87
|
+
unless maf
|
88
|
+
raise ArgumentError.new("*** don't know how to convert remotely from xml #{input} to txt #{output}")
|
89
|
+
end
|
90
|
+
url = URI(XML2RFC_WEBSERVICE)
|
91
|
+
req = Net::HTTP::Post.new(url)
|
92
|
+
form = [["modeAsFormat", maf],
|
93
|
+
["type", "binary"],
|
94
|
+
["input", File.open(input),
|
95
|
+
{filename: "input.xml",
|
96
|
+
content_type: "text/plain"}]]
|
97
|
+
diag = ["url/form: ", url, form].inspect
|
98
|
+
req.set_form(form, 'multipart/form-data')
|
99
|
+
res = Net::HTTP::start(url.hostname, url.port,
|
100
|
+
:use_ssl => url.scheme == 'https' ) {|http|
|
101
|
+
http.request(req)
|
102
|
+
}
|
103
|
+
case res
|
104
|
+
when Net::HTTPOK
|
105
|
+
case res.content_type
|
106
|
+
when 'application/octet-stream'
|
107
|
+
if res.body == ''
|
108
|
+
raise IOError.new("*** HTTP response is empty with status #{res.code}, not written")
|
109
|
+
end
|
110
|
+
File.open(output, "w") do |fo|
|
111
|
+
fo.print(res.body)
|
112
|
+
end
|
113
|
+
warn "* #{output} written" if @options.verbose
|
114
|
+
else
|
115
|
+
warning = "*** HTTP response has unexpected content_type #{res.content_type} with status #{res.code}, #{diag}"
|
116
|
+
warning << "\n"
|
117
|
+
warning << res.body
|
118
|
+
raise IOError.new(warning)
|
119
|
+
end
|
120
|
+
else
|
121
|
+
raise IOError.new("*** HTTP response: #{res.code}, #{diag}")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def process_the_xml(fn, base)
|
126
|
+
process_xml(fn, "#{base}.prepped.xml", "--preptool") if @options.prep
|
127
|
+
process_xml(fn, "#{base}.v2v3.xml", "--v2v3") if @options.v2v3
|
128
|
+
process_xml(fn, "#{base}.txt") if @options.txt || @options.idnits
|
129
|
+
process_xml(fn, "#{base}.html", "--html") if @options.html
|
130
|
+
process_xml(fn, "#{base}.pdf", "--pdf") if @options.pdf
|
131
|
+
run_idnits("#{base}.txt") if @options.idnits
|
132
|
+
end
|
133
|
+
|
134
|
+
def process(fn)
|
135
|
+
case fn
|
136
|
+
when /(.*)\.xml\z/
|
137
|
+
if @options.xml_only
|
138
|
+
warn "*** You already have XML"
|
139
|
+
else # FIXME: copy/paste
|
140
|
+
process_the_xml(fn, $1)
|
141
|
+
end
|
142
|
+
when /(.*)\.mk?d\z/
|
143
|
+
xml = "#$1.xml"
|
144
|
+
process_mkd(fn, xml)
|
145
|
+
process_the_xml(xml, $1) unless @options.xml_only
|
146
|
+
else
|
147
|
+
raise ArgumentError.new("Unknown file type: #{fn}")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# (((
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
data/lib/kramdown-rfc/refxml.rb
CHANGED
@@ -57,17 +57,35 @@ module KramdownRFC
|
|
57
57
|
aups
|
58
58
|
end
|
59
59
|
|
60
|
+
# The below anticipates the "postalLine" changes.
|
61
|
+
# If a postalLine is used (abbreviated "postal" in YAML),
|
62
|
+
# non-postalLine elements are appended as further postalLines.
|
63
|
+
# This prepares for how "country" is expected to be handled
|
64
|
+
# specially with the next schema update.
|
65
|
+
# So an address is now best keyboarded as:
|
66
|
+
# postal:
|
67
|
+
# - Foo Street
|
68
|
+
# - 28359 Bar
|
69
|
+
# country: Germany
|
70
|
+
|
60
71
|
PERSON_ERB = <<~ERB
|
61
72
|
<<%= element_name%> <%=aups.attrs("initials", "surname", "fullname=name", "role")%>>
|
62
73
|
<%= aups.ele("organization=org", aups.attrs("abbrev=orgabbrev",
|
63
74
|
*[$options.v3 && "ascii=orgascii"]), "") %>
|
64
75
|
<address>
|
65
|
-
<%
|
66
|
-
if
|
76
|
+
<% postal_elements = %w{extaddr pobox street cityarea city region code sortingcode country postal}.select{|gi| aups.has(gi)}
|
77
|
+
if postal_elements != [] -%>
|
67
78
|
<postal>
|
68
|
-
<%
|
79
|
+
<% if pl = postal_elements.delete("postal") -%>
|
80
|
+
<%= aups.ele("postalLine=postal") %>
|
81
|
+
<% postal_elements.each do |gi| -%>
|
82
|
+
<%= aups.ele("postalLine=" << gi) %>
|
83
|
+
<% end -%>
|
84
|
+
<% else -%>
|
85
|
+
<% postal_elements.each do |gi| -%>
|
69
86
|
<%= aups.ele(gi) %>
|
70
87
|
<% end -%>
|
88
|
+
<% end -%>
|
71
89
|
</postal>
|
72
90
|
<% end -%>
|
73
91
|
<% %w{phone facsimile email uri}.select{|gi| aups.has(gi)}.each do |gi| -%>
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -53,6 +53,9 @@ module Kramdown
|
|
53
53
|
|
54
54
|
def self.idref_cleanup(href)
|
55
55
|
# can't start an IDREF with a number or reserved start
|
56
|
+
if href =~ / /
|
57
|
+
warn "** space(s) in cross-reference '#{href}' -- are you trying to use section references?"
|
58
|
+
end
|
56
59
|
href.gsub(/\A(?:[0-9]|section-|u-|figure-|table-|iref-)/) { "_#{$&}" }
|
57
60
|
end
|
58
61
|
|
@@ -125,9 +128,14 @@ module Kramdown
|
|
125
128
|
when /\A(.*) \((#{SECTIONS_RE})\)\z/
|
126
129
|
href = $1
|
127
130
|
handle_bares($2, attr, "parens", href)
|
128
|
-
when
|
129
|
-
href = $
|
130
|
-
|
131
|
+
when /#{XREF_RE_M}<(.+)\z/
|
132
|
+
href = $3
|
133
|
+
if $2
|
134
|
+
attr['section'] = $2
|
135
|
+
attr['relative'] = "#" << $1
|
136
|
+
else
|
137
|
+
attr['section'] = $1
|
138
|
+
end
|
131
139
|
attr['sectionFormat'] = 'bare'
|
132
140
|
when /\A<<(.+)\z/
|
133
141
|
href = $1
|
@@ -371,8 +379,20 @@ COLORS
|
|
371
379
|
end
|
372
380
|
end
|
373
381
|
|
382
|
+
SVG_NAMESPACES = {"xmlns"=>"http://www.w3.org/2000/svg",
|
383
|
+
"xlink"=>"http://www.w3.org/1999/xlink"}
|
384
|
+
|
374
385
|
def svg_clean_kgt(s)
|
375
386
|
d = REXML::Document.new(s)
|
387
|
+
REXML::XPath.each(d.root, "/xmlns:svg", SVG_NAMESPACES) do |x|
|
388
|
+
if (w = x.attributes["width"]) && (h = x.attributes["height"])
|
389
|
+
x.attributes["viewBox"] = "0 0 %d %d" % [w, h]
|
390
|
+
end
|
391
|
+
if x.attributes["viewBox"]
|
392
|
+
x.attributes["width"] = nil
|
393
|
+
x.attributes["height"] = nil
|
394
|
+
end
|
395
|
+
end
|
376
396
|
REXML::XPath.each(d.root, "//rect|//line|//path") do |x|
|
377
397
|
x.attributes["fill"] = "none"
|
378
398
|
x.attributes["stroke"] = "black"
|
@@ -545,8 +565,17 @@ COLORS
|
|
545
565
|
|
546
566
|
def convert_blockquote(el, indent, opts)
|
547
567
|
text = inner(el, indent, opts)
|
568
|
+
if $options.v3
|
569
|
+
gi = el.attr.delete('gi')
|
570
|
+
if gi && gi != 'ul'
|
571
|
+
"#{' '*indent}<#{gi}#{el_html_attributes(el)}>\n#{text}#{' '*indent}</#{gi}>\n"
|
572
|
+
else
|
573
|
+
"#{' '*indent}<ul#{el_html_attributes_with(el, {"empty" => 'true'})}><li>\n#{text}#{' '*indent}</li></ul>\n"
|
574
|
+
end
|
575
|
+
else
|
548
576
|
text = "<t></t>" unless text =~ /</ # empty block quote
|
549
577
|
"#{' '*indent}<t><list style='empty'#{el_html_attributes(el)}>\n#{text}#{' '*indent}</list></t>\n"
|
578
|
+
end
|
550
579
|
end
|
551
580
|
|
552
581
|
def end_sections(to_level, indent)
|
@@ -1032,18 +1061,30 @@ COLORS
|
|
1032
1061
|
# this would be more like xml2rfc v3:
|
1033
1062
|
# "\n#{' '*indent}<cref>\n#{inner(el.value, indent, opts).rstrip}\n#{' '*indent}</cref>"
|
1034
1063
|
content = inner(el.value, indent, opts).strip
|
1035
|
-
content =
|
1064
|
+
content = content.sub(/\A<t>(.*)<\/t>\z/m) {$1}
|
1036
1065
|
name = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(el.options[:name])
|
1066
|
+
o_name = name.dup
|
1037
1067
|
while @footnote_names_in_use[name] do
|
1038
|
-
if name =~
|
1068
|
+
if name =~ /_\d+\z/
|
1039
1069
|
name.succ!
|
1040
1070
|
else
|
1041
|
-
name << "
|
1071
|
+
name << "_1"
|
1042
1072
|
end
|
1043
1073
|
end
|
1044
1074
|
@footnote_names_in_use[name] = true
|
1045
1075
|
attrstring = el_html_attributes_with(el, {"anchor" => name})
|
1046
|
-
|
1076
|
+
if $options.v3
|
1077
|
+
if o_name[-1] == "-"
|
1078
|
+
# Ignore HTML attributes. Hmm.
|
1079
|
+
content
|
1080
|
+
else
|
1081
|
+
# do not indent span-level so we can stick to previous word. Good?
|
1082
|
+
"<cref#{attrstring}>#{content}</cref>"
|
1083
|
+
end
|
1084
|
+
else
|
1085
|
+
content = escape_html(content, :text) # text only...
|
1086
|
+
"\n#{' '*indent}<cref#{attrstring}>#{content}</cref>"
|
1087
|
+
end
|
1047
1088
|
end
|
1048
1089
|
|
1049
1090
|
def convert_raw(el, indent, opts)
|
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.4
|
4
|
+
version: 1.5.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: 2021-07-
|
11
|
+
date: 2021-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- kramdown-rfc2629.gemspec
|
81
81
|
- lib/kramdown-rfc/erb.rb
|
82
82
|
- lib/kramdown-rfc/gzip-clone.rb
|
83
|
+
- lib/kramdown-rfc/kdrfc-processor.rb
|
83
84
|
- lib/kramdown-rfc/parameterset.rb
|
84
85
|
- lib/kramdown-rfc/refxml.rb
|
85
86
|
- lib/kramdown-rfc2629.rb
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
|
-
rubygems_version: 3.2.
|
106
|
+
rubygems_version: 3.2.22
|
106
107
|
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Kramdown extension for generating RFC 7749 XML.
|