kramdown-rfc2629 1.6.36 → 1.6.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/doilit +5 -1
- data/bin/kramdown-rfc-extract-sourcecode +1 -1
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/command.rb +1 -1
- data/lib/kramdown-rfc/doi.rb +46 -15
- data/lib/kramdown-rfc2629.rb +1 -2
- 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: ea81e522df55255e9f76abebbbf3d804539252441a2d9d5b3fc1a2997a0382b4
|
4
|
+
data.tar.gz: e9382ad7bac6dcd7602a32123d79e968c1aeabeec7a381529dd52df6848127f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c93291f8b176f0f06e7cefb4d88eb8bd9b0519235e36e8acb796a10f1db9bc7a0e15b7635ed479b6df7334062b946215b7153ab322ae4d4f7b39bc03fa62ddff
|
7
|
+
data.tar.gz: bea4113567f46ec383d0f4c0dc19b9607fcb8be30411cf683e76783d3710f2a3b88201e40ef4a1fd6adb6902767bd42d53f3bfa85e6f7dfca8553e26f078e23c
|
data/bin/doilit
CHANGED
@@ -11,6 +11,7 @@ $verbose = false
|
|
11
11
|
$fuzzy = false
|
12
12
|
$handle = "a"
|
13
13
|
$xml = false
|
14
|
+
$site = "https://dx.doi.org"
|
14
15
|
|
15
16
|
litent = {}
|
16
17
|
ARGV.each do |doi|
|
@@ -28,6 +29,9 @@ ARGV.each do |doi|
|
|
28
29
|
when "-v"
|
29
30
|
$verbose = true
|
30
31
|
next
|
32
|
+
when /\A-s=(.*)/
|
33
|
+
$site = $1
|
34
|
+
next
|
31
35
|
when /\A-h=(.*)/
|
32
36
|
$handle = $1
|
33
37
|
next
|
@@ -40,7 +44,7 @@ ARGV.each do |doi|
|
|
40
44
|
exit 1
|
41
45
|
end
|
42
46
|
|
43
|
-
lit = doi_fetch_and_convert(doi, fuzzy: $fuzzy, verbose: $verbose)
|
47
|
+
lit = doi_fetch_and_convert(doi, fuzzy: $fuzzy, verbose: $verbose, site: $site)
|
44
48
|
|
45
49
|
while litent[$handle]
|
46
50
|
$handle.succ!
|
@@ -25,7 +25,7 @@ begin
|
|
25
25
|
opts.on("-dDIR", "--dir=DIR", "Target directory (default: sourcecode)") do |v|
|
26
26
|
dir = v
|
27
27
|
end
|
28
|
-
opts.on("-f", "--[no-]unfold", "
|
28
|
+
opts.on("-f", "--[no-]unfold", "RFC8792-unfold (default: yes)") do |v|
|
29
29
|
unfold = v
|
30
30
|
end
|
31
31
|
end
|
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.6.
|
3
|
+
s.version = '1.6.37'
|
4
4
|
s.summary = "Kramdown extension for generating RFCXML (RFC 799x)."
|
5
5
|
s.description = %{An RFCXML (RFC 799x) generating backend for Thomas Leitner's
|
6
6
|
"kramdown" markdown parser. Mostly useful for RFC writers.}
|
data/lib/kramdown-rfc/command.rb
CHANGED
data/lib/kramdown-rfc/doi.rb
CHANGED
@@ -4,13 +4,35 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
ACCEPT_CITE_JSON = {"Accept" => "application/citeproc+json"}
|
6
6
|
|
7
|
-
def doi_fetch_and_convert(doi, fuzzy: false, verbose: false)
|
7
|
+
def doi_fetch_and_convert(doi, fuzzy: false, verbose: false, site: "https://dx.doi.org")
|
8
8
|
doipath = doi.sub(/^([0-9.]+)_/) {"#$1/"} # convert initial _ back to /
|
9
9
|
# warn "** SUB #{doi} #{doipath}" if doi != doipath
|
10
|
-
|
11
|
-
|
10
|
+
begin
|
11
|
+
cite = JSON.parse(URI("#{site}/#{doipath}").open(ACCEPT_CITE_JSON).read)
|
12
|
+
puts cite.to_yaml if verbose
|
13
|
+
doi_citeproc_to_lit(cite, fuzzy)
|
14
|
+
rescue OpenURI::HTTPError => e
|
15
|
+
begin
|
16
|
+
site = "https://dl.acm.org"
|
17
|
+
percent_escaped = doipath.gsub("/", "%2F")
|
18
|
+
path = "#{site}/action/exportCiteProcCitation?targetFile=custom-bibtex&format=bibTex&dois=#{percent_escaped}"
|
19
|
+
op = URI(path).open # first get a cookie, ignore result
|
20
|
+
# warn [:META, op.meta].inspect
|
21
|
+
cook = op.meta['set-cookie'].split('; ', 2)[0]
|
22
|
+
cite = JSON.parse(URI(path).open("Cookie" => cook).read)
|
23
|
+
cite = cite["items"].first[doipath]
|
24
|
+
puts cite.to_yaml if verbose
|
25
|
+
doi_citeproc_to_lit(cite, fuzzy)
|
26
|
+
rescue
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def doi_citeproc_to_lit(cite, fuzzy)
|
12
33
|
lit = {}
|
13
34
|
ser = lit["seriesinfo"] = {}
|
35
|
+
refcontent = []
|
14
36
|
lit["title"] = cite["title"]
|
15
37
|
if (st = cite["subtitle"]) && Array === st # defensive
|
16
38
|
st.delete('')
|
@@ -76,19 +98,28 @@ def doi_fetch_and_convert(doi, fuzzy: false, verbose: false)
|
|
76
98
|
spl = ct.split(" ")
|
77
99
|
ser[spl[0..-2].join(" ")] = spl[-1]
|
78
100
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
101
|
+
end
|
102
|
+
if pub = cite["publisher"]
|
103
|
+
refcontent << pub
|
104
|
+
# info = []
|
105
|
+
# if t = cite["type"]
|
106
|
+
# info << t
|
107
|
+
# end
|
108
|
+
# rhs = info.join(", ")
|
109
|
+
# if info != []
|
110
|
+
# ser[pub] = rhs
|
111
|
+
# else
|
112
|
+
# spl = pub.split(" ")
|
113
|
+
# ser[spl[0..-2].join(" ")] = spl[-1]
|
114
|
+
# end
|
115
|
+
end
|
116
|
+
["DOI", "ISBN"].each do |st|
|
117
|
+
if a = cite[st]
|
118
|
+
ser[st] = a
|
90
119
|
end
|
91
120
|
end
|
92
|
-
|
121
|
+
if refcontent != []
|
122
|
+
lit["refcontent"] = refcontent.join(", ")
|
123
|
+
end
|
93
124
|
lit
|
94
125
|
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -548,11 +548,10 @@ COLORS
|
|
548
548
|
stdin_data: result);
|
549
549
|
err << err1.to_s
|
550
550
|
when "math", "math-asciitex"
|
551
|
-
math = Shellwords.escape(result)
|
552
551
|
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false#{svg_opt} #{Shellwords.escape(' ' << result)}");
|
553
552
|
begin
|
554
553
|
raise Errno::ENOENT if t == "math-asciitex"
|
555
|
-
result, err1, s = Open3.capture3("utftex -m #{
|
554
|
+
result, err1, s = Open3.capture3("utftex -m #{txt_opt}", stdin_data: result)
|
556
555
|
if s.exitstatus != 0
|
557
556
|
warn "** utftex: #{err1.inspect}"
|
558
557
|
raise Errno::ENOENT
|
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.6.
|
4
|
+
version: 1.6.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|