kramdown-rfc2629 1.3.31 → 1.3.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +48 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a63a768cc08e589dd15a5d52c77d3567ecd689ed5521ecb2f4772ee6b933a88
|
4
|
+
data.tar.gz: db71bef12f52b7777f1a19b84ff5c19bf1f37835761291b2aaaa626b92d67c54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51deb8472aa941d6c7d21ec8e60173064a59cb426ccd3e48fdc2fad463a633197077be21a4d7298d08c32280d4df79e0a4990da23d39b96b94a881a27e6f5a91
|
7
|
+
data.tar.gz: f38b8bde3c0464622b652994f67c0fb9bc501bd3fd3c7d53f3536d0e0dc251f8b706b38550967a268c1b21e156e272f78c3aafac4899621ed7077447bc5e0f91
|
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.32'
|
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
@@ -178,6 +178,17 @@ module Kramdown
|
|
178
178
|
|
179
179
|
# :stopdoc:
|
180
180
|
|
181
|
+
KRAMDOWN_PERSISTENT = ENV["KRAMDOWN_PERSISTENT"]
|
182
|
+
|
183
|
+
if KRAMDOWN_PERSISTENT
|
184
|
+
begin
|
185
|
+
require 'net/http/persistent'
|
186
|
+
$http = Net::HTTP::Persistent.new name: 'kramdown-rfc'
|
187
|
+
rescue Exception => e
|
188
|
+
warn "** Can't set up persistent HTTP -- #{e}"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
181
192
|
# Defines the amount of indentation used when nesting XML tags.
|
182
193
|
INDENTATION = 2
|
183
194
|
|
@@ -682,6 +693,34 @@ COLORS
|
|
682
693
|
KRAMDOWN_OFFLINE = ENV["KRAMDOWN_OFFLINE"]
|
683
694
|
KRAMDOWN_REFCACHE_REFETCH = ENV["KRAMDOWN_REFCACHE_REFETCH"]
|
684
695
|
|
696
|
+
def get_and_write_resource(url, fn)
|
697
|
+
options = {}
|
698
|
+
if ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
|
699
|
+
options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
700
|
+
end # workaround for OpenSSL on Windows...
|
701
|
+
# URI.open(url, **options) do |uf| # not portable to older versions
|
702
|
+
OpenURI.open_uri(url, **options) do |uf|
|
703
|
+
s = uf.read
|
704
|
+
if uf.status[0] != "200"
|
705
|
+
warn "*** Status code #{status} while fetching #{url}"
|
706
|
+
else
|
707
|
+
File.write(fn, s)
|
708
|
+
end
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
def get_and_write_resource_persistently(url, fn)
|
713
|
+
t1 = Time.now
|
714
|
+
response = $http.request(URI(url))
|
715
|
+
if response.code != "200"
|
716
|
+
raise "Status code #{response.code} while fetching #{url}"
|
717
|
+
else
|
718
|
+
File.write(fn, response.body)
|
719
|
+
end
|
720
|
+
t2 = Time.now
|
721
|
+
warn "(#{"%.3f" % (t2 - t1)} s)"
|
722
|
+
end
|
723
|
+
|
685
724
|
# this is now slightly dangerous as multiple urls could map to the same cachefile
|
686
725
|
def get_and_cache_resource(url, cachefile, tvalid = 7200, tn = Time.now)
|
687
726
|
fn = "#{REFCACHEDIR}/#{cachefile}"
|
@@ -710,18 +749,15 @@ COLORS
|
|
710
749
|
require 'timeout'
|
711
750
|
begin
|
712
751
|
Timeout::timeout(fetch_timeout) do
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
s = uf.read
|
720
|
-
if uf.status[0] != "200"
|
721
|
-
warn "*** Status code #{status} while fetching #{url}"
|
722
|
-
else
|
723
|
-
File.write(fn, s)
|
752
|
+
if $http
|
753
|
+
begin # belt and suspenders
|
754
|
+
get_and_write_resource_persistently(url, fn)
|
755
|
+
rescue Exception => e
|
756
|
+
warn "*** Can't get with persistent HTTP: #{e}"
|
757
|
+
get_and_write_resource(url, fn)
|
724
758
|
end
|
759
|
+
else
|
760
|
+
get_and_write_resource(url, fn)
|
725
761
|
end
|
726
762
|
end
|
727
763
|
rescue OpenURI::HTTPError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
@@ -788,7 +824,7 @@ COLORS
|
|
788
824
|
to_insert = ""
|
789
825
|
src.scan(/(W3C|3GPP|[A-Z-]+)[.]?([A-Za-z_0-9.\/\+-]+)/) do |t, n|
|
790
826
|
fn = "reference.#{t}.#{n}.xml"
|
791
|
-
sub, ttl,
|
827
|
+
sub, ttl, _can_anchor, altproc = XML_RESOURCE_ORG_MAP[t]
|
792
828
|
ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
|
793
829
|
puts "*** Huh: #{fn}" unless sub
|
794
830
|
if altproc && !KRAMDOWN_USE_TOOLS_SERVER
|
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.3.
|
4
|
+
version: 1.3.32
|
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-02-
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|