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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97b4e9ec1d3932d44efbc35c4028e44440c1f307f9a56ec2d56562096c8a2ad0
4
- data.tar.gz: 36ace3e7ea222e805b39c3ab5595b3ef96604200de89b960a2a8d9a38b86593c
3
+ metadata.gz: ea81e522df55255e9f76abebbbf3d804539252441a2d9d5b3fc1a2997a0382b4
4
+ data.tar.gz: e9382ad7bac6dcd7602a32123d79e968c1aeabeec7a381529dd52df6848127f4
5
5
  SHA512:
6
- metadata.gz: 1dc62f9a6a680ff30093413be469d75d4c078044835a981c1273e90cbb02f1b77e2dee16860424ba4c8215261636e2d9cc15dd08151274597cb61e85320bc1b9
7
- data.tar.gz: bb50e8274dc61b28f501b63f17aec1094a91b9f6fff3cb758ccf4197a79105e7ee99c99f2d51e2dedf61187e8c9bba22e4ef6fc2c2020e3383b2a67153089932
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", "RFC8972-unfold (default: yes)") do |v|
28
+ opts.on("-f", "--[no-]unfold", "RFC8792-unfold (default: yes)") do |v|
29
29
  unfold = v
30
30
  end
31
31
  end
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.6.36'
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.}
@@ -314,7 +314,7 @@ def xml_from_sections(input)
314
314
  anchor_to_bibref[k] = bibref
315
315
  end
316
316
  if dr = v.delete("display")
317
- displayref[k] = dr
317
+ displayref[k.gsub("/", "_")] = dr
318
318
  end
319
319
  end
320
320
  end
@@ -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
- cite = JSON.parse(URI("https://dx.doi.org/#{doipath}").open(ACCEPT_CITE_JSON).read)
11
- puts cite.to_yaml if verbose
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
- elsif pub = cite["publisher"]
80
- info = []
81
- if t = cite["type"]
82
- info << t
83
- end
84
- rhs = info.join(", ")
85
- if info != []
86
- ser[pub] = rhs
87
- else
88
- spl = pub.split(" ")
89
- ser[spl[0..-2].join(" ")] = spl[-1]
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
- ser["DOI"] = cite["DOI"]
121
+ if refcontent != []
122
+ lit["refcontent"] = refcontent.join(", ")
123
+ end
93
124
  lit
94
125
  end
@@ -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 #{math}#{txt_opt}")
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.36
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-28 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown