kramdown-rfc2629 1.0.37 → 1.0.38

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: 08b41268ed6569d07045e9c7c6250559d71593bd
4
- data.tar.gz: 62e9537a4bf8aa32ff3aeb451ca50c4f319fceea
3
+ metadata.gz: a66985def68028e27c86bd2848c2508d1087d3b3
4
+ data.tar.gz: edfe9404687740f8617fc82fd2c4bb8e1bd85835
5
5
  SHA512:
6
- metadata.gz: 79ec13be311cce2766846f83d0e35b4f16260fa7cb308d14f79d94e5c3fbd346aafe51a366942d9aafa25343d3e705bc6aefd9312acb03cdca742fee11e3bd2d
7
- data.tar.gz: 6e787f88ad5bbd7bf002a77ba89aa6f6a7754a3118c9a07b87c8a8d7ea1d78af6268b69d988f4bffa8ef41a0d200a102a9b1355b037344a1c4efa92329e114be
6
+ metadata.gz: f2a957ed2f5dbba350d6a792e145ad859182002f3e512178745eda3a3e00c26fc76272c0902275e338160aa57e61f12382d7a71513ca91388c01f9f67d4709a3
7
+ data.tar.gz: 87a051613d3d3998b740c3ce9a449cdea87f3324e24d839a66db81975f3309de5c61aa50afa2b61655c363d852db4363302b2398a96e99d1fa73755247cb6340
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby -KU
2
+ require 'kramdown-rfc/gzip-clone'
3
+ require 'base64'
4
+
5
+ EMBEDDED_RE = %r{<!-- ##markdown-source:\s*([A-Za-z0-9+/=\s]+)-->}
6
+ embedded = ARGF.read.scan(EMBEDDED_RE)
7
+ unless embedded.empty?
8
+ puts Gzip.decompress(Base64.decode64(embedded[0][0]))
9
+ else
10
+ warn "*** No embedded markdown source found!"
11
+ end
data/bin/kramdown-rfc2629 CHANGED
@@ -17,6 +17,14 @@ NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
17
17
  NORMINFORM = { "!" => :normative, "?" => :informative }
18
18
 
19
19
  def xml_from_sections(input)
20
+
21
+ unless ENV["KRAMDOWN_NO_SOURCE"]
22
+ require 'kramdown-rfc/gzip-clone'
23
+ require 'base64'
24
+ compressed_input = Gzip.compress(input)
25
+ $source = Base64.encode64(compressed_input)
26
+ end
27
+
20
28
  sections = input.scan(RE_SECTION)
21
29
  # resulting in an array; each section is [section-label, nomarkdown-flag, section-text]
22
30
 
@@ -198,6 +206,7 @@ if input =~ /[\t]/
198
206
  warn "*** Input contains HT (\"tab\") characters. Undefined behavior will ensue."
199
207
  input = expand_tabs(input)
200
208
  end
209
+
201
210
  link_defs = {}
202
211
  if input =~ /\A---/ # this is a sectionized file
203
212
  input, target_coding, link_defs, smart_quotes = xml_from_sections(input)
@@ -225,6 +234,7 @@ if target_coding
225
234
  input = input.encode(Encoding.find(target_coding), fallback: FALLBACK)
226
235
  end
227
236
 
237
+
228
238
  # warn "options: #{options.inspect}"
229
239
  doc = Kramdown::Document.new(input, options)
230
240
  $stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
@@ -98,4 +98,11 @@
98
98
  <%= sechash.delete("back") %>
99
99
 
100
100
  </back>
101
+
102
+ <% if $source -%>
103
+ <!-- ##markdown-source:
104
+ <%= $source %>
105
+ -->
106
+ <% end -%>
107
+
101
108
  </rfc>
@@ -1,13 +1,13 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.0.37'
3
+ s.version = '1.0.38'
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.12.0')
8
- s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kramdown-rfc2629 bin/doilit data/kramdown-rfc2629.erb data/encoding-fallbacks.txt)
8
+ 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
9
  s.require_path = 'lib'
10
- s.executables = ['kramdown-rfc2629', 'doilit']
10
+ s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown']
11
11
  s.default_executable = 'kramdown-rfc2629'
12
12
  s.required_ruby_version = '>= 1.9.2'
13
13
  # s.requirements = 'wget'
@@ -0,0 +1,36 @@
1
+ require 'zlib'
2
+ require 'stringio'
3
+
4
+ # cloned from module ActiveSupport
5
+ # A convenient wrapper for the zlib standard library that allows
6
+ # compression/decompression of strings with gzip.
7
+ #
8
+ # gzip = Gzip.compress('compress me!')
9
+ # # => "\x1F\x8B\b\x00o\x8D\xCDO\x00\x03K\xCE\xCF-(J-.V\xC8MU\x04\x00R>n\x83\f\x00\x00\x00"
10
+ #
11
+ # Gzip.decompress(gzip)
12
+ # # => "compress me!"
13
+ module Gzip
14
+ class Stream < StringIO
15
+ def initialize(*)
16
+ super
17
+ set_encoding "BINARY"
18
+ end
19
+ def close; rewind; end
20
+ end
21
+
22
+ # Decompresses a gzipped string.
23
+ def self.decompress(source)
24
+ Zlib::GzipReader.new(StringIO.new(source)).read
25
+ end
26
+
27
+ # Compresses a string using gzip.
28
+ def self.compress(source, level=Zlib::DEFAULT_COMPRESSION, strategy=Zlib::DEFAULT_STRATEGY)
29
+ output = Stream.new
30
+ gz = Zlib::GzipWriter.new(output, level, strategy)
31
+ gz.write(source)
32
+ gz.close
33
+ output.string
34
+ end
35
+ end
36
+ # 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.0.37
4
+ version: 1.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -31,16 +31,19 @@ email: cabo@tzi.org
31
31
  executables:
32
32
  - kramdown-rfc2629
33
33
  - doilit
34
+ - kramdown-rfc-extract-markdown
34
35
  extensions: []
35
36
  extra_rdoc_files: []
36
37
  files:
37
38
  - LICENSE
38
39
  - README.md
39
40
  - bin/doilit
41
+ - bin/kramdown-rfc-extract-markdown
40
42
  - bin/kramdown-rfc2629
41
43
  - data/encoding-fallbacks.txt
42
44
  - data/kramdown-rfc2629.erb
43
45
  - kramdown-rfc2629.gemspec
46
+ - lib/kramdown-rfc/gzip-clone.rb
44
47
  - lib/kramdown-rfc/parameterset.rb
45
48
  - lib/kramdown-rfc/refxml.rb
46
49
  - lib/kramdown-rfc2629.rb