kramdown-rfc2629 1.6.8 → 1.6.11

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: 6d59387d706ba44ac2ac591f8d2dbddeae8d1a4b451fa8252b6231f655fbce56
4
- data.tar.gz: f059d6c8a0006257317423d23c5a8478b722e00bf33d441e7f892d67248fa2bb
3
+ metadata.gz: a7e2b28056c1ef692cd6de23d4436dd71ee6be8020d276f400965b61b59d779c
4
+ data.tar.gz: 143b99d9d781337fc783fc993504d4e691dc24ce4f228f7132e02dc6594c3bc0
5
5
  SHA512:
6
- metadata.gz: 93865dc7e09b2a905a58873beb724d9d7a8c7b66b2d012c88bd562fa0ecc667558b44765c304a174d339c8ea89b4cb6e72b47aa35463e0ba6dba6e0d3909dc16
7
- data.tar.gz: c85e67c72649fd7fd702713572118300e10d24146c04008ba681b892ed985fc1c4918f9bf3a7f61b040096fe4bc29ded9b3c1632fd89cabb47a54cb6571589a3
6
+ metadata.gz: b39291781b26db62fb2cf7c37f00d2a855b1f50d725c3a4e6dbba56eea1e3f432ceb93dc2adbda26ed8f59bca0a59519ccf24cbef23c62b97600599120da8811
7
+ data.tar.gz: 7631706a9ac2935ff3d882ff34910dd1db0a7fcebe2ccd7e4648a012ad50cff8a5afbbb52e5ca1d40e98680ddf1bbf2228592130345580d4a5ca8d8fd64762d6
data/bin/doilit CHANGED
@@ -12,6 +12,7 @@ require 'kramdown-rfc/refxml'
12
12
  ACCEPT_CITE_JSON = {"Accept" => "application/citeproc+json"}
13
13
 
14
14
  $verbose = false
15
+ $fuzzy = false
15
16
  $handle = "a"
16
17
  $xml = false
17
18
 
@@ -25,6 +26,9 @@ ARGV.each do |doi|
25
26
  warn '*** please "gem install open-uri-cached" to enable caching'
26
27
  end
27
28
  next
29
+ when "-f"
30
+ $fuzzy = true
31
+ next
28
32
  when "-v"
29
33
  $verbose = true
30
34
  next
@@ -36,7 +40,7 @@ ARGV.each do |doi|
36
40
  $xml = true
37
41
  next
38
42
  when /\A-/
39
- warn "*** Usage: doilit [-c] [-v] [-h=handle|-x=xmlhandle] doi..."
43
+ warn "*** Usage: doilit [-c] [-f] [-v] [-h=handle|-x=xmlhandle] doi..."
40
44
  exit 1
41
45
  end
42
46
  cite = JSON.parse(URI("https://dx.doi.org/#{doi}").open(ACCEPT_CITE_JSON).read)
@@ -72,6 +76,13 @@ ARGV.each do |doi|
72
76
  end
73
77
  end
74
78
  end
79
+ if !lit.key?("date") && $fuzzy && (iss = cite["created"])
80
+ if dp = iss["date-parts"]
81
+ if Integer === (dp = dp[0])[0]
82
+ lit["date"] = ["%04d" % dp[0], *dp[1..-1].map {|p| "%02d" % p}].join("-")
83
+ end
84
+ end
85
+ end
75
86
  if (ct = cite["container-title"]) && ct != []
76
87
  info = []
77
88
  if v = cite["volume"]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'rexml/document'
4
+ require 'kramdown-rfc/autolink-iref-cleanup'
5
+
6
+ d = REXML::Document.new(ARGF.read)
7
+ autolink_iref_cleanup(d)
8
+ puts d.to_s
@@ -29,7 +29,7 @@
29
29
  ps["consensus"] = true if MUST_CONSENSUS[cat]
30
30
  end
31
31
  rfcattrs = ps.attrs("ipr", "docName=docname", "category=cat",
32
- "consensus", "submissionType=submissiontype", "xml:lang=lang",
32
+ "consensus", "submissionType=submissiontype=stream", "xml:lang=lang",
33
33
  "number", "obsoletes", "updates", "seriesNo=seriesno")
34
34
  TRUE_FALSE = {nil => "true", false => "false", true => "true",
35
35
  "yes" => "true", "no" => "false"}
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.6.8'
3
+ s.version = '1.6.11'
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.}
@@ -8,11 +8,13 @@ spec = Gem::Specification.new do |s|
8
8
  s.add_dependency('kramdown-parser-gfm', '~> 1.1')
9
9
  s.add_dependency('certified', '~> 1.0')
10
10
  s.add_dependency('json_pure', '~> 2.0')
11
- s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/kramdown-rfc-autolink-iref-cleanup.rb bin/de-gfm)
11
+ s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/kramdown-rfc-autolink-iref-cleanup bin/de-gfm)
12
12
  s.require_path = 'lib'
13
13
  s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
14
14
  'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
15
- 'kramdown-rfc-cache-subseries-bibxml', 'de-gfm']
15
+ 'kramdown-rfc-cache-subseries-bibxml',
16
+ 'kramdown-rfc-autolink-iref-cleanup',
17
+ 'de-gfm']
16
18
  s.required_ruby_version = '>= 2.3.0'
17
19
  # s.requirements = 'wget'
18
20
  # s.has_rdoc = true
@@ -0,0 +1,29 @@
1
+ require 'rexml/document'
2
+
3
+ def autolink_iref_cleanup(d)
4
+
5
+ d.root.get_elements("//section[@anchor]").each do |sec|
6
+ anchor = sec['anchor']
7
+ irefs = {}
8
+ sec.get_elements(".//xref[@target='#{anchor}'][@format='none']").each do |xr|
9
+ ne = xr.next_element
10
+ if ne && ne.name == "iref" && (item = ne['item'])
11
+ irefs[item] = ne['subitem'] # XXX one subitem only
12
+ ne.remove
13
+ chi = xr.children
14
+ chi[1..-1].reverse.each do |ch|
15
+ xr.parent.insert_after(xr, ch)
16
+ end
17
+ xr.replace_with(chi[0])
18
+ end
19
+ end
20
+ irefs.each do |k, v|
21
+ sec.insert_after(sec.get_elements("name").first,
22
+ e = REXML::Element.new("iref", sec))
23
+ e.attributes["item"] = k
24
+ e.attributes["subitem"] = v
25
+ e.attributes["primary"] = 'true'
26
+ end
27
+ end
28
+
29
+ end
@@ -254,6 +254,10 @@ def xml_from_sections(input)
254
254
  end
255
255
  end
256
256
 
257
+ if o = ps[:'autolink-iref-cleanup']
258
+ $options.autolink_iref_cleanup = o
259
+ end
260
+
257
261
  coding_override = ps.has(:coding)
258
262
  smart_quotes = ps[:smart_quotes]
259
263
  typographic_symbols = ps[:typographic_symbols]
@@ -570,6 +574,15 @@ if $options.v3_used && !$options.v3
570
574
  $options.v3 = true
571
575
  end
572
576
 
577
+ if $options.autolink_iref_cleanup
578
+ require 'rexml/document'
579
+ require 'kramdown-rfc/autolink-iref-cleanup'
580
+
581
+ d = REXML::Document.new(output)
582
+ autolink_iref_cleanup(d)
583
+ output = d.to_s
584
+ end
585
+
573
586
  if coding_override
574
587
  output = output.encode(Encoding.find(coding_override), fallback: FALLBACK)
575
588
  end
@@ -27,13 +27,15 @@ module KramdownRFC
27
27
  def has(pn)
28
28
  @f[pn.to_s]
29
29
  end
30
+ def has?(pn)
31
+ @f.key?(pn.to_s)
32
+ end
30
33
  def escattr(str)
31
34
  escape_html(str.to_s, :attribute)
32
35
  end
33
- def van(pn) # pn is a parameter name, possibly with an =alias
34
- an, pn = pn.to_s.split("=")
35
- pn ||= an
36
- [self[pn] || self[an], an]
36
+ def van(pn) # pn is a parameter name, possibly with =aliases
37
+ names = pn.to_s.split("=")
38
+ [self[names.reverse.find{|nm| has?(nm)}], names.first]
37
39
  end
38
40
  def attr(pn)
39
41
  val, an = van(pn)
@@ -14,7 +14,7 @@ raise "sorry, 1.8 was last decade" unless RUBY_VERSION >= '1.9'
14
14
 
15
15
  gem 'kramdown', '~> 2.4.0'
16
16
  require 'kramdown'
17
- my_span_elements = %w{list figure xref eref iref cref spanx vspace}
17
+ my_span_elements = %w{list xref eref iref cref spanx vspace}
18
18
  Kramdown::Parser::Html::Constants::HTML_SPAN_ELEMENTS.concat my_span_elements
19
19
 
20
20
  require 'rexml/parsers/baseparser'
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.8
4
+ version: 1.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-30 00:00:00.000000000 Z
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -78,6 +78,7 @@ executables:
78
78
  - kdrfc
79
79
  - kramdown-rfc-cache-i-d-bibxml
80
80
  - kramdown-rfc-cache-subseries-bibxml
81
+ - kramdown-rfc-autolink-iref-cleanup
81
82
  - de-gfm
82
83
  extensions: []
83
84
  extra_rdoc_files: []
@@ -88,7 +89,7 @@ files:
88
89
  - bin/doilit
89
90
  - bin/kdrfc
90
91
  - bin/kramdown-rfc
91
- - bin/kramdown-rfc-autolink-iref-cleanup.rb
92
+ - bin/kramdown-rfc-autolink-iref-cleanup
92
93
  - bin/kramdown-rfc-cache-i-d-bibxml
93
94
  - bin/kramdown-rfc-cache-subseries-bibxml
94
95
  - bin/kramdown-rfc-extract-markdown
@@ -97,6 +98,7 @@ files:
97
98
  - data/kramdown-rfc2629.erb
98
99
  - data/math.json
99
100
  - kramdown-rfc2629.gemspec
101
+ - lib/kramdown-rfc/autolink-iref-cleanup.rb
100
102
  - lib/kramdown-rfc/command.rb
101
103
  - lib/kramdown-rfc/erb.rb
102
104
  - lib/kramdown-rfc/gzip-clone.rb
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
- require 'rexml/document'
4
-
5
- d = REXML::Document.new(ARGF.read)
6
-
7
- d.root.get_elements("//section[@anchor]").each do |sec|
8
- anchor = sec['anchor']
9
- irefs = {}
10
- sec.get_elements(".//xref[@target='#{anchor}'][@format='none']").each do |xr|
11
- ne = xr.next_element
12
- if ne && ne.name == "iref" && (item = ne['item'])
13
- irefs[item] = ne['subitem'] # XXX one subitem only
14
- ne.remove
15
- chi = xr.children
16
- chi[1..-1].reverse.each do |ch|
17
- xr.parent.insert_after(xr, ch)
18
- end
19
- xr.replace_with(chi[0])
20
- end
21
- end
22
- irefs.each do |k, v|
23
- sec.insert_after(sec.get_elements("name").first,
24
- e = REXML::Element.new("iref", sec))
25
- e.attributes["item"] = k
26
- e.attributes["subitem"] = v
27
- e.attributes["primary"] = 'true'
28
- end
29
- end
30
-
31
- puts d.to_s