kramdown-rfc2629 1.6.36 → 1.6.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
  SHA256:
3
- metadata.gz: 97b4e9ec1d3932d44efbc35c4028e44440c1f307f9a56ec2d56562096c8a2ad0
4
- data.tar.gz: 36ace3e7ea222e805b39c3ab5595b3ef96604200de89b960a2a8d9a38b86593c
3
+ metadata.gz: 8b4707d20a26b963bdbf7423a2cc460769d6336d2ff01b47a3f74ec34f9a09fc
4
+ data.tar.gz: 3371f7774a039bf5effefb353baf1ffb7e1ccac76369db43f0f77c9b6e4284be
5
5
  SHA512:
6
- metadata.gz: 1dc62f9a6a680ff30093413be469d75d4c078044835a981c1273e90cbb02f1b77e2dee16860424ba4c8215261636e2d9cc15dd08151274597cb61e85320bc1b9
7
- data.tar.gz: bb50e8274dc61b28f501b63f17aec1094a91b9f6fff3cb758ccf4197a79105e7ee99c99f2d51e2dedf61187e8c9bba22e4ef6fc2c2020e3383b2a67153089932
6
+ metadata.gz: ab844b01fc405878b32920b37ee05bc9354c6a5d3d9a2adf2eeeeca1862e89ebec0b94d7638afb893de745c3142d69ad4aecfa534f814dc7288b4208cb226fce
7
+ data.tar.gz: 60f42e7ded57af960bf618078eaa6d3f16591fc8099b897b1d5d7108bcf38b4e50c4123d198d1409197488f6ef7ab5678788c40bf42c097ccb859b6a09ebbe05
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!
@@ -4,6 +4,7 @@ require 'yaml'
4
4
  require 'shellwords'
5
5
  require 'fileutils'
6
6
  require_relative '../lib/kramdown-rfc/rfc8792'
7
+ require_relative '../lib/kramdown-rfc/rexml-all-text.rb'
7
8
 
8
9
  def clean(s)
9
10
  s.gsub!(/\//, ":")
@@ -25,7 +26,7 @@ begin
25
26
  opts.on("-dDIR", "--dir=DIR", "Target directory (default: sourcecode)") do |v|
26
27
  dir = v
27
28
  end
28
- opts.on("-f", "--[no-]unfold", "RFC8972-unfold (default: yes)") do |v|
29
+ opts.on("-f", "--[no-]unfold", "RFC8792-unfold (default: yes)") do |v|
29
30
  unfold = v
30
31
  end
31
32
  end
@@ -51,7 +52,8 @@ d = REXML::Document.new(ARGF)
51
52
  REXML::XPath.each(d.root, "//sourcecode|//artwork") do |x|
52
53
  if ty = x[:type]
53
54
  ty = clean(ty)
54
- name = x[:name] || gensym.succ!
55
+ name = x[:name]
56
+ name = gensym.succ! if !name || name.empty?
55
57
  name = clean(name)
56
58
  if taken[ty][name]
57
59
  unless warned[ty][name]
@@ -61,7 +63,7 @@ REXML::XPath.each(d.root, "//sourcecode|//artwork") do |x|
61
63
  else
62
64
  taken[ty][name] = ''
63
65
  end
64
- taken[ty][name] << handle_artwork_sourcecode(x.text, unfold)
66
+ taken[ty][name] << handle_artwork_sourcecode(x.all_text, unfold)
65
67
  end
66
68
  end
67
69
 
@@ -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.38'
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.}
@@ -266,7 +266,7 @@ def xml_from_sections(input)
266
266
  end
267
267
 
268
268
  coding_override = ps.has(:coding)
269
- smart_quotes = ps[:smart_quotes]
269
+ smart_quotes = ps[:smart_quotes] || ps[:"smart-quotes"]
270
270
  typographic_symbols = ps[:typographic_symbols]
271
271
  header_kramdown_options = ps[:kramdown_options]
272
272
 
@@ -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
@@ -0,0 +1,20 @@
1
+ require 'rexml/document'
2
+
3
+ module REXML
4
+ # all_text: Get all text from descendants that are Text or CData
5
+ class Element
6
+ def all_text
7
+ @children.map {|c| c.all_text}.join
8
+ end
9
+ end
10
+ class Text # also: ancestor of CData
11
+ def all_text
12
+ value
13
+ end
14
+ end
15
+ class Child
16
+ def all_text
17
+ ''
18
+ end
19
+ end
20
+ 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.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: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -182,6 +182,7 @@ files:
182
182
  - lib/kramdown-rfc/kdrfc-processor.rb
183
183
  - lib/kramdown-rfc/parameterset.rb
184
184
  - lib/kramdown-rfc/refxml.rb
185
+ - lib/kramdown-rfc/rexml-all-text.rb
185
186
  - lib/kramdown-rfc/rexml-formatters-conservative.rb
186
187
  - lib/kramdown-rfc/rfc8792.rb
187
188
  - lib/kramdown-rfc/svg-id-cleanup.rb