kramdown-rfc2629 1.3.27 → 1.3.32
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 +4 -4
- data/README.md +15 -4
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +78 -22
- 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/README.md
CHANGED
@@ -294,13 +294,24 @@ output generated by the tool (e.g., `plantuml-utxt`).
|
|
294
294
|
|
295
295
|
Currently supported labels as of 1.3.9:
|
296
296
|
|
297
|
-
* goat, ditaa: ASCII (plaintext) art to figure conversion
|
298
|
-
* mscgen: Message Sequence Charts
|
299
|
-
* plantuml: widely used multi-purpose diagram generator
|
297
|
+
* [goat][], [ditaa][]: ASCII (plaintext) art to figure conversion
|
298
|
+
* [mscgen][]: Message Sequence Charts
|
299
|
+
* [plantuml][]: widely used multi-purpose diagram generator
|
300
300
|
* plantuml-utxt: Like plantuml, except that a plantuml-generated
|
301
301
|
plaintext form is used
|
302
|
-
* mermaid: Very experimental; the conversion to SVG is prone to
|
302
|
+
* [mermaid][]: Very experimental; the conversion to SVG is prone to
|
303
303
|
generate black-on-black text in this version
|
304
|
+
* math: display math using [tex2svg][] for HTML/PDF and [asciitex][]
|
305
|
+
(fork: [asciiTeX][asciiTeX-eggert]) for plaintext
|
306
|
+
|
307
|
+
[goat]: https://github.com/blampe/goat
|
308
|
+
[ditaa]: https://github.com/stathissideris/ditaa
|
309
|
+
[mscgen]: http://www.mcternan.me.uk/mscgen/
|
310
|
+
[plantuml]: https://plantuml.com
|
311
|
+
[mermaid]: https://github.com/mermaid-js/mermaid-cli
|
312
|
+
[tex2svg]: https://github.com/mathjax/MathJax-demos-node/blob/master/direct/tex2svg
|
313
|
+
[asciitex]: http://asciitex.sourceforge.net/
|
314
|
+
[asciiTeX-eggert]: https://github.com/larseggert/asciiTeX
|
304
315
|
|
305
316
|
Note that this feature does not play well with the CI (continuous
|
306
317
|
integration) support in Martin Thomson's [I-D Template][], as that may
|
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
|
|
@@ -289,7 +300,12 @@ COLORS
|
|
289
300
|
REXML::XPath.each(d.root, "//*[@fill]") { |x| x.attributes["fill"] = svg_munch_color(x.attributes["fill"], true) }
|
290
301
|
REXML::XPath.each(d.root, "//*[@id]") { |x| x.attributes["id"] = svg_munch_id(x.attributes["id"]) }
|
291
302
|
## REXML::XPath.each(d.root, "//rect") { |x| x.attributes["style"] = "fill:none;stroke:black;stroke-width:1" unless x.attributes["style"] }
|
303
|
+
# Fix for mermaid:
|
304
|
+
REXML::XPath.each(d.root, "//polygon") { |x| x.attributes["rx"] = nil; x.attributes["ry"] = nil }
|
292
305
|
d.to_s
|
306
|
+
rescue => detail
|
307
|
+
warn "*** Can't clean SVG: #{detail}"
|
308
|
+
d
|
293
309
|
end
|
294
310
|
|
295
311
|
def memoize(meth, *args)
|
@@ -330,13 +346,13 @@ COLORS
|
|
330
346
|
when "mermaid"
|
331
347
|
result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
|
332
348
|
outpath = file.path + ".svg"
|
333
|
-
result1 = File.read(outpath)
|
334
|
-
File.unlink(outpath)
|
349
|
+
result1 = File.read(outpath) rescue '' # don't die before providing error message
|
350
|
+
File.unlink(outpath) rescue nil # ditto
|
335
351
|
when "plantuml", "plantuml-utxt"
|
336
352
|
plantuml = "@startuml\n#{result}\n@enduml"
|
337
353
|
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
|
338
354
|
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
339
|
-
err << err1
|
355
|
+
err << err1.to_s
|
340
356
|
when "math"
|
341
357
|
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
|
342
358
|
result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
|
@@ -349,6 +365,10 @@ COLORS
|
|
349
365
|
result1, err, _s = Open3.capture3("svgcheck -qa", stdin_data: result1);
|
350
366
|
capture_croak("svgcheck", err)
|
351
367
|
# warn ["svgcheck:", result1.inspect]
|
368
|
+
if result1 == ''
|
369
|
+
warn "*** could not create svg for #{result.inspect[0...20]}..."
|
370
|
+
exit 65 # EX_DATAERR
|
371
|
+
end
|
352
372
|
[result, result1] # text, svg
|
353
373
|
end
|
354
374
|
|
@@ -673,6 +693,34 @@ COLORS
|
|
673
693
|
KRAMDOWN_OFFLINE = ENV["KRAMDOWN_OFFLINE"]
|
674
694
|
KRAMDOWN_REFCACHE_REFETCH = ENV["KRAMDOWN_REFCACHE_REFETCH"]
|
675
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
|
+
|
676
724
|
# this is now slightly dangerous as multiple urls could map to the same cachefile
|
677
725
|
def get_and_cache_resource(url, cachefile, tvalid = 7200, tn = Time.now)
|
678
726
|
fn = "#{REFCACHEDIR}/#{cachefile}"
|
@@ -686,7 +734,7 @@ COLORS
|
|
686
734
|
message = "fetching"
|
687
735
|
fetch_timeout = 60 # seconds; long timeout needed for Travis
|
688
736
|
end
|
689
|
-
$stderr.puts "#{fn}: #{message}"
|
737
|
+
$stderr.puts "#{fn}: #{message} from #{url}"
|
690
738
|
if ENV["HAVE_WGET"]
|
691
739
|
`cd #{REFCACHEDIR}; wget -t 3 -T #{fetch_timeout} -Nnv "#{url}"` # ignore errors if offline (hack)
|
692
740
|
begin
|
@@ -701,18 +749,15 @@ COLORS
|
|
701
749
|
require 'timeout'
|
702
750
|
begin
|
703
751
|
Timeout::timeout(fetch_timeout) do
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
s = uf.read
|
711
|
-
if uf.status[0] != "200"
|
712
|
-
warn "*** Status code #{status} while fetching #{url}"
|
713
|
-
else
|
714
|
-
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)
|
715
758
|
end
|
759
|
+
else
|
760
|
+
get_and_write_resource(url, fn)
|
716
761
|
end
|
717
762
|
end
|
718
763
|
rescue OpenURI::HTTPError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
@@ -730,8 +775,12 @@ COLORS
|
|
730
775
|
|
731
776
|
# [subdirectory name, cache ttl in seconds, does it provide for ?anchor=]
|
732
777
|
XML_RESOURCE_ORG_MAP = {
|
733
|
-
"RFC" => ["bibxml", 86400*7
|
734
|
-
|
778
|
+
"RFC" => ["bibxml", 86400*7, false,
|
779
|
+
->(fn, n){ "https://www.rfc-editor.org/refs/bibxml/#{fn}"}
|
780
|
+
],
|
781
|
+
"I-D" => ["bibxml3", false, false,
|
782
|
+
->(fn, n){ "https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}/xml" }
|
783
|
+
],
|
735
784
|
"W3C" => "bibxml4",
|
736
785
|
"3GPP" => "bibxml5",
|
737
786
|
"ANSI" => "bibxml2",
|
@@ -752,6 +801,7 @@ COLORS
|
|
752
801
|
XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml2rfc.tools.ietf.org"
|
753
802
|
XML_RESOURCE_ORG_PREFIX = ENV["XML_RESOURCE_ORG_PREFIX"] ||
|
754
803
|
"https://#{XML_RESOURCE_ORG_HOST}/public/rfc"
|
804
|
+
KRAMDOWN_USE_TOOLS_SERVER = ENV["KRAMDOWN_USE_TOOLS_SERVER"]
|
755
805
|
|
756
806
|
KRAMDOWN_REFCACHETTL = (e = ENV["KRAMDOWN_REFCACHETTL"]) ? e.to_i : 3600
|
757
807
|
|
@@ -774,16 +824,22 @@ COLORS
|
|
774
824
|
to_insert = ""
|
775
825
|
src.scan(/(W3C|3GPP|[A-Z-]+)[.]?([A-Za-z_0-9.\/\+-]+)/) do |t, n|
|
776
826
|
fn = "reference.#{t}.#{n}.xml"
|
777
|
-
sub, ttl,
|
827
|
+
sub, ttl, _can_anchor, altproc = XML_RESOURCE_ORG_MAP[t]
|
778
828
|
ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
|
779
829
|
puts "*** Huh: #{fn}" unless sub
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
830
|
+
if altproc && !KRAMDOWN_USE_TOOLS_SERVER
|
831
|
+
url = altproc.call(fn, n)
|
832
|
+
else
|
833
|
+
url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
|
784
834
|
end
|
835
|
+
# if can_anchor # create anchor server-side for stand_alone: false
|
836
|
+
# url << "?anchor=#{anchor}"
|
837
|
+
# fn[/.xml$/] = "--anchor=#{anchor}.xml"
|
838
|
+
# end
|
785
839
|
to_insert = get_and_cache_resource(url, fn.gsub('/', '_'), ttl)
|
786
840
|
to_insert.scrub! rescue nil # only do this for Ruby >= 2.1
|
841
|
+
to_insert.gsub!(%r{target="https?://www.ietf.org/internet-drafts/},
|
842
|
+
%{target="https://www.ietf.org/archive/id/}) if t == "I-D"
|
787
843
|
# this may be a bit controversial: Don't break the build if reference is broken
|
788
844
|
if KRAMDOWN_OFFLINE
|
789
845
|
unless to_insert
|
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
|