kramdown-rfc2629 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kdrfc +14 -5
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +17 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cdf03ff424a3911001953ad3890547406acc73568b3f6a3a474b5e0cb2a2ead
|
4
|
+
data.tar.gz: 1b444ffd149931d0bc83a79d94d2eb8862d90f2bd3b4534194928146db6d5939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 316a02ae7a37a32c6f875175d38b18d34a2104b812ea6a46889f33e65df84dfcc66458bdfbf26a577fa634766d2d37150ad2b4938b90f3e153cb092457d2a64a
|
7
|
+
data.tar.gz: 4a456d50fe6eed21d68229a2647a4ede87e4e5189c434e2167a02c7a8f1e5b0534dfd2cc0c6aed46262acbc2d9aaa97e67f0082a7088c715f1c9baef7e7ec002
|
data/bin/kdrfc
CHANGED
@@ -29,10 +29,10 @@ def process_xml(*args)
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def process_xml_locally(input, output)
|
32
|
+
def process_xml_locally(input, output, *flags)
|
33
33
|
warn "* converting locally from xml #{input} to txt #{output}" if $options.verbose
|
34
34
|
begin
|
35
|
-
o, s = Open3.capture2("xml2rfc", *v3_flag?, input)
|
35
|
+
o, s = Open3.capture2("xml2rfc", *v3_flag?, *flags, input)
|
36
36
|
puts o
|
37
37
|
if s.success?
|
38
38
|
warn "* #{output} written" if $options.verbose
|
@@ -83,6 +83,7 @@ require 'optparse'
|
|
83
83
|
require 'ostruct'
|
84
84
|
|
85
85
|
$options = OpenStruct.new
|
86
|
+
$options.txt = true # default
|
86
87
|
op = OptionParser.new do |opts|
|
87
88
|
opts.banner = "Usage: kdrfc [options] file.md|file.mkd|file.xml"
|
88
89
|
|
@@ -95,6 +96,12 @@ op = OptionParser.new do |opts|
|
|
95
96
|
opts.on("-x", "--[no-]xml", "Convert to xml only") do |v|
|
96
97
|
$options.xml_only = v
|
97
98
|
end
|
99
|
+
opts.on("-h", "--[no-]html", "Convert to html as well") do |v|
|
100
|
+
$options.html = v
|
101
|
+
end
|
102
|
+
opts.on("-t", "--[no-]txt", "Convert to txt as well") do |v|
|
103
|
+
$options.txt = v
|
104
|
+
end
|
98
105
|
opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
|
99
106
|
$options.v3 = v
|
100
107
|
end
|
@@ -108,13 +115,15 @@ when 1
|
|
108
115
|
when /(.*)\.xml\z/
|
109
116
|
if $options.xml_only
|
110
117
|
warn "*** You already have XML"
|
111
|
-
else
|
112
|
-
process_xml(fn, "#$1.txt")
|
118
|
+
else # FIXME: copy/paste
|
119
|
+
process_xml(fn, "#$1.txt") unless $options.xml_only or not $options.txt
|
120
|
+
process_xml(fn, "#$1.html", "--html") unless $options.xml_only or not $options.html
|
113
121
|
end
|
114
122
|
when /(.*)\.mk?d\z/
|
115
123
|
xml = "#$1.xml"
|
116
124
|
process_mkd(fn, xml)
|
117
|
-
process_xml(xml, "#$1.txt") unless $options.xml_only
|
125
|
+
process_xml(xml, "#$1.txt") unless $options.xml_only or not $options.txt
|
126
|
+
process_xml(xml, "#$1.html", "--html") unless $options.xml_only or not $options.html
|
118
127
|
else
|
119
128
|
warn "Unknown file type: #{fn}"
|
120
129
|
exit 1
|
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.3.
|
3
|
+
s.version = '1.3.2'
|
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.}
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -172,11 +172,12 @@ module Kramdown
|
|
172
172
|
"#{' '*indent}<t>#{result}</t>\n"
|
173
173
|
else
|
174
174
|
artwork_attr = {}
|
175
|
+
t = nil
|
175
176
|
if blockclass
|
176
177
|
classes = blockclass.split(' ')
|
177
178
|
classes.each do |cl|
|
178
179
|
if md = cl.match(/\Alanguage-(.*)/)
|
179
|
-
artwork_attr["type"] = md[1] # XXX overwrite
|
180
|
+
t = artwork_attr["type"] = md[1] # XXX overwrite
|
180
181
|
else
|
181
182
|
$stderr.puts "*** Unimplemented block class: #{cl}"
|
182
183
|
end
|
@@ -192,7 +193,21 @@ module Kramdown
|
|
192
193
|
artwork_attr[md[1]] = v
|
193
194
|
end
|
194
195
|
end
|
195
|
-
|
196
|
+
case t
|
197
|
+
when "goat"
|
198
|
+
require 'tempfile'
|
199
|
+
file = Tempfile.new("kramdown-rfc")
|
200
|
+
file.write(result)
|
201
|
+
file.close
|
202
|
+
result1, _s = Open3.capture2("goat #{file.path}", stdin_data: result);
|
203
|
+
# warn ["goat:", result1.inspect]
|
204
|
+
file.unlink
|
205
|
+
result1, _s = Open3.capture2("svgcheck -qa", stdin_data: result1);
|
206
|
+
# warn ["svgcheck:", result1.inspect]
|
207
|
+
"#{' '*indent}<figure#{el_html_attributes(el)}><artset><artwork #{html_attributes(artwork_attr.merge("type"=> "svg"))}>#{result1.sub(/.*?<svg/m, "<svg")}</artwork><artwork #{html_attributes(artwork_attr.merge("type"=> "ascii-art"))}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></artset></figure>\n"
|
208
|
+
else
|
209
|
+
"#{' '*indent}<figure#{el_html_attributes(el)}><artwork#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></figure>\n"
|
210
|
+
end
|
196
211
|
end
|
197
212
|
end
|
198
213
|
|