kramdown-rfc2629 1.6.9 → 1.6.12
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/bin/doilit +12 -1
- data/bin/kramdown-rfc-autolink-iref-cleanup +8 -0
- data/kramdown-rfc2629.gemspec +5 -3
- data/lib/kramdown-rfc/autolink-iref-cleanup.rb +29 -0
- data/lib/kramdown-rfc/command.rb +13 -0
- data/lib/kramdown-rfc2629.rb +6 -5
- metadata +5 -3
- data/bin/kramdown-rfc-autolink-iref-cleanup.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3949475273a7c4f72acf86a47d2c9fb176c2a6f81c8d9cc9db03d595c61248
|
4
|
+
data.tar.gz: 165b94bb4a9306134e92515dae4eec7a9022b0264d95484d7f31a316982d3b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1686e35bd93c3e9ff63f42bb830845e3b7accf1b2b7621fb78d49b0fafc3c1edeaea53a645c6e81d8ee5c9f468c54fb0920cb91831325c210d9b98d810f64564
|
7
|
+
data.tar.gz: 5599b22f40492bbfffc8a5d34af3e9ddc69452757bc0c9eb95a97ce312bdc730d3858ffbe1b00bce3af8377d651a3277d3ec82acd0b62e65f7436c8051797bd7
|
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"]
|
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.12'
|
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
|
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',
|
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
|
data/lib/kramdown-rfc/command.rb
CHANGED
@@ -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
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -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
|
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'
|
@@ -37,7 +37,7 @@ module Kramdown
|
|
37
37
|
def replace_abbreviations(el, regexps = nil)
|
38
38
|
unless regexps # DUPLICATED AND MODIFIED CODE FROM UPSTREAM, CHECK ON UPSTREAM UPGRADE
|
39
39
|
sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length }
|
40
|
-
regexps = [Regexp.union(*sorted_abbrevs.map {|k|
|
40
|
+
regexps = [Regexp.union(*sorted_abbrevs.map {|k|
|
41
41
|
/#{Regexp.escape(k).gsub(/\\\s/, "[\\s\\p{Z}]+").force_encoding(Encoding::UTF_8)}/})]
|
42
42
|
# warn regexps.inspect
|
43
43
|
regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
|
@@ -721,7 +721,7 @@ COLORS
|
|
721
721
|
if sl = el.attr.delete('slugifiedName') # could do general name- play
|
722
722
|
attrstring = html_attributes({'slugifiedName' => sl})
|
723
723
|
end
|
724
|
-
# noabbrev: true -- Workaround for https://
|
724
|
+
# noabbrev: true -- Workaround for https://github.com/ietf-tools/xml2rfc/issues/683
|
725
725
|
nm = inner(el, indent, opts.merge(noabbrev: true))
|
726
726
|
if ttl = el.attr['title']
|
727
727
|
warn "*** Section has two titles: >>#{ttl}<< and >>#{nm}<<"
|
@@ -1057,7 +1057,7 @@ COLORS
|
|
1057
1057
|
def self.bcp_std_ref(t, n)
|
1058
1058
|
warn "*** #{t} anchors not supported in v2 format" unless $options.v3
|
1059
1059
|
[name = "reference.#{t}.#{"%04d" % n.to_i}.xml",
|
1060
|
-
"#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries
|
1060
|
+
"#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries/#{name}"] # FOR NOW
|
1061
1061
|
end
|
1062
1062
|
|
1063
1063
|
# [subdirectory name, cache ttl in seconds, does it provide for ?anchor=]
|
@@ -1094,7 +1094,8 @@ COLORS
|
|
1094
1094
|
}
|
1095
1095
|
|
1096
1096
|
# XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml.resource.org"
|
1097
|
-
XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml2rfc.tools.ietf.org"
|
1097
|
+
# XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml2rfc.tools.ietf.org"
|
1098
|
+
XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "bib.ietf.org"
|
1098
1099
|
XML_RESOURCE_ORG_PREFIX = ENV["XML_RESOURCE_ORG_PREFIX"] ||
|
1099
1100
|
"https://#{XML_RESOURCE_ORG_HOST}/public/rfc"
|
1100
1101
|
KRAMDOWN_USE_TOOLS_SERVER = ENV["KRAMDOWN_USE_TOOLS_SERVER"]
|
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.12
|
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-
|
11
|
+
date: 2022-06-27 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
|
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
|