kramdown-rfc2629 1.3.1 → 1.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f43b8d0d98aa61a451d6e85635aaa71e5a48820a679c5d7338f41dac367995a
4
- data.tar.gz: 93e1654b15e3c5c226dc00f562fa95c4e6ca41f348af2d64e5f2c410dc6d3f1f
3
+ metadata.gz: 3cdf03ff424a3911001953ad3890547406acc73568b3f6a3a474b5e0cb2a2ead
4
+ data.tar.gz: 1b444ffd149931d0bc83a79d94d2eb8862d90f2bd3b4534194928146db6d5939
5
5
  SHA512:
6
- metadata.gz: e44c716d95d3d05ac48f1da768241cdd2dcc8472d3ab9b56f4515a17f6e2798b183e21cce8086c0cdb81691c730f0330c95dcdf54e5f6ec06938298012e67f6d
7
- data.tar.gz: 4176998414bed9502ff2d8a8114dfed8b7a3abee0032546aa9c64d50ba3095b6b75b84df3045235716d104e053060b49c34e6552862659c1a9171a74fc7b5c07
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
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.1'
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.}
@@ -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
- "#{' '*indent}<figure#{el_html_attributes(el)}><artwork#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></figure>\n"
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann