kramdown-rfc2629 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae2b6bf131f870712854d26c556777f300ebb961
4
- data.tar.gz: b9256d830f7d04b3ef36c7c126ed8b38532f727b
3
+ metadata.gz: 3eddcf63f4104b7055bb8a022ddb37c75d9c0e18
4
+ data.tar.gz: c8b2131d960d0e14149c5f1d61cf8165dc462009
5
5
  SHA512:
6
- metadata.gz: 884f08d588fc0df4b4e1c65da4182113a491e347d5f9a17e8eb014b712382c08ba45accf98f8894205a6284539cdbdfb8e37989c63c507ed0f6cec946ccf1a8f
7
- data.tar.gz: 32ccd7f29129e334981adb3caba507b9d72558a5e9b233a655b35cea33c66e048ad76fdf4e816bdc5681df3be868c6a3bf8073df5634c541a914099fb4b1c8c1
6
+ metadata.gz: b10a872278edda1366b90cb7d11265552e86e94f98a41ae16c2e5456b82e7cc49bddfd679fca7a1a83b0d9551df0002c2aba832bd95c6256bc13c38300ca15e2
7
+ data.tar.gz: 9e3550e46f1fd56959d716d9b6df7e16d9e0b396a2534337cfa7eae5cc38da3c335812571dcd769396fdd6f21f8784f0745947cd2002937c7d29078add9ba306
data/bin/kdrfc ADDED
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env ruby -KU
2
+ require 'uri'
3
+ require 'net/http'
4
+ require 'open3'
5
+
6
+ def process_mkd(input, output)
7
+ warn "* converting locally from markdown #{input} to xml #{output}" if $options.verbose
8
+ o, s = Open3.capture2("kramdown-rfc2629", input)
9
+ if s.success?
10
+ File.open(output, "w") do |fo|
11
+ fo.print(o)
12
+ end
13
+ warn "* #{output} written" if $options.verbose
14
+ else
15
+ warn "*** kramdown-rfc failed, status #{s.exitstatus}"
16
+ exit 1
17
+ end
18
+ end
19
+
20
+ def process_xml(*args)
21
+ if $options.remote
22
+ process_xml_remotely(*args)
23
+ else
24
+ process_xml_locally(*args)
25
+ end
26
+ end
27
+
28
+ def process_xml_locally(input, output)
29
+ warn "* converting locally from xml #{input} to txt #{output}" if $options.verbose
30
+ begin
31
+ o, s = Open3.capture2("xml2rfc", input)
32
+ puts o
33
+ if s.success?
34
+ warn "* #{output} written" if $options.verbose
35
+ else
36
+ warn "*** xml2rfc failed, status #{s.exitstatus} (possibly try with -r)"
37
+ exit 1
38
+ end
39
+ rescue Errno::ENOENT
40
+ warn "*** falling back to remote processing" if $options.verbose
41
+ process_xml_remotely(input, output)
42
+ end
43
+ end
44
+
45
+ def process_xml_remotely(input, output)
46
+ warn "* converting remotely from xml #{input} to txt #{output}" if $options.verbose
47
+ url = URI('http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi')
48
+ req = Net::HTTP::Post.new(url)
49
+ req.set_form([["modeAsFormat", "txt/ascii"],
50
+ ["type", "binary"],
51
+ ["input", File.open(input),
52
+ {filename: "input.xml",
53
+ content_type: "text/plain"}]],
54
+ 'multipart/form-data')
55
+ res = Net::HTTP::start(url.hostname, url.port,
56
+ :use_ssl => url.scheme == 'https' ) {|http|
57
+ http.request(req)
58
+ }
59
+ case res
60
+ when Net::HTTPOK
61
+ case res.content_type
62
+ when 'application/octet-stream'
63
+ File.open(output, "w") do |fo|
64
+ fo.print(res.body)
65
+ end
66
+ warn "* #{output} written" if $options.verbose
67
+ else
68
+ warn "*** HTTP response has unexpected content_type #{res.content_type} with status #{res.code}"
69
+ warn res.body
70
+ exit 1
71
+ end
72
+ else
73
+ warn "*** HTTP response: #{res.code}"
74
+ exit 1
75
+ end
76
+ end
77
+
78
+ require 'optparse'
79
+ require 'ostruct'
80
+
81
+ $options = OpenStruct.new
82
+ op = OptionParser.new do |opts|
83
+ opts.banner = "Usage: kdrfc [options] file.md|file.mkd|file.xml"
84
+
85
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
86
+ $options.verbose = v
87
+ end
88
+ opts.on("-r", "--[no-]remote", "Run xml2rfc remotely even if there is a local one") do |v|
89
+ $options.remote = v
90
+ end
91
+ opts.on("-x", "--[no-]xml", "Convert to xml only") do |v|
92
+ $options.xml_only = v
93
+ end
94
+ end
95
+ op.parse!
96
+
97
+ case ARGV.size
98
+ when 1
99
+ fn = ARGV[0]
100
+ case fn
101
+ when /(.*)\.xml\z/
102
+ if $options.xml_only
103
+ warn "*** You already have XML"
104
+ else
105
+ process_xml(fn, "#$1.txt")
106
+ end
107
+ when /(.*)\.mk?d\z/
108
+ xml = "#$1.xml"
109
+ process_mkd(fn, xml)
110
+ process_xml(xml, "#$1.txt") unless $options.xml_only
111
+ else
112
+ warn "Unknown file type: #{fn}"
113
+ exit 1
114
+ end
115
+ else
116
+ puts op
117
+ exit 1
118
+ end
data/bin/kramdown-rfc2629 CHANGED
@@ -259,7 +259,7 @@ end
259
259
 
260
260
  link_defs = {}
261
261
  if input =~ /\A---/ # this is a sectionized file
262
- do_the_tls_dance
262
+ do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
263
263
  input, target_coding, link_defs, smart_quotes = xml_from_sections(input)
264
264
  end
265
265
  if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
@@ -1,14 +1,14 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.1.2'
3
+ s.version = '1.2.0'
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.}
7
7
  s.add_dependency('kramdown', '~> 1.13.0')
8
8
  s.add_dependency('certified', '~> 1.0')
9
- s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt)
9
+ s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt)
10
10
  s.require_path = 'lib'
11
- s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown']
11
+ s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown', 'kdrfc']
12
12
  s.default_executable = 'kramdown-rfc2629'
13
13
  s.required_ruby_version = '>= 1.9.2'
14
14
  # s.requirements = 'wget'
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.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-15 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -46,12 +46,14 @@ executables:
46
46
  - kramdown-rfc2629
47
47
  - doilit
48
48
  - kramdown-rfc-extract-markdown
49
+ - kdrfc
49
50
  extensions: []
50
51
  extra_rdoc_files: []
51
52
  files:
52
53
  - LICENSE
53
54
  - README.md
54
55
  - bin/doilit
56
+ - bin/kdrfc
55
57
  - bin/kramdown-rfc-extract-markdown
56
58
  - bin/kramdown-rfc2629
57
59
  - data/encoding-fallbacks.txt