kramdown-rfc2629 1.7.19 → 1.7.21

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: f9d9adbae37a16a29017726ef2040d260eb1a2cce9d00ff807828c84275d87eb
4
- data.tar.gz: 6018923d328495fb77b78886e467d9c24267bc563d37c71dd527c11c7ee1e709
3
+ metadata.gz: b359e547f2f8f265b1ee961d2956c32073d4a846a4fa813bd9ff8f898d385f08
4
+ data.tar.gz: 72ecb5162fc2910ceb62d3ee7df6e6902f1fe15540d2761b1e94ee73c60cffb7
5
5
  SHA512:
6
- metadata.gz: 5f9e4452395530cd215d5fa3f1c701cd393091424e25e42b564f26c55eb2e6d7601e5da7e87dee2cc6587041b960a76c0aa449277b4ac323b4dc4238a595d3af
7
- data.tar.gz: d7e408eca15365eb9b8c653dcd3f3dc78a040e6dc599a8e959e7e8ac59e0c630b196d716511ed345547aa5cc1707a1bf2af6a972d83dbeae3fa6ebbebc3ab8b1
6
+ metadata.gz: a65c817ecab99a017c3335f1e8040ffb37f1e1915e32abea9253cabd7f12014d4176ca2ab8fdd3659ea3d546b9e3ead4c3fd4c7f33ca62f8dd6b3b79bb87606c
7
+ data.tar.gz: 226b74d1c1a011bbe8631598d91d01c6defaf228c38735405bd86a36456aba3edc74a3cfc27a1e3e91a3f5aa9a7d8075dd34fa35b1b2082ccddea9b339b5a543
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby -KU
2
+ require 'rexml/document'
3
+ require 'yaml'
4
+ require 'optparse'
5
+
6
+ PROGNAME = $0 # "kramdown-rfc-extract-figures-tables"
7
+
8
+ target = :section
9
+ targets = [:section, :note]
10
+ require 'optparse'
11
+ begin
12
+ op = OptionParser.new do |opts|
13
+ opts.banner = "Usage: #{PROGNAME} [options] [-|document.xml]"
14
+ opts.on("-tFMT", "--to=FMT", targets, "Target format #{targets.map(&:to_s)}") do |v|
15
+ target = v
16
+ end
17
+ end
18
+ op.parse!
19
+ rescue Exception => e
20
+ warn e
21
+ exit 1
22
+ end
23
+
24
+ class String
25
+ def spacify
26
+ gsub(/\s+/, " ")
27
+ end
28
+ end
29
+
30
+ lists = Hash.new { |h, k| h[k] = [] }
31
+ d = REXML::Document.new(ARGF)
32
+ unless d.root
33
+ warn "** #{PROGNAME}: Cannot parse input"
34
+ exit 1
35
+ end
36
+ REXML::XPath.each(d.root, %{//figure|//*[name()="table" or name()="texttable"]}) do |x|
37
+ gi = x.name
38
+ ref = x[:anchor]
39
+ # p [gi, ref]
40
+ out = []
41
+ REXML::XPath.each(x, "name") do |nm|
42
+ out << nm.children.map{|ch| ch.to_s}.join
43
+ # p [gi, out.last]
44
+ end
45
+ REXML::XPath.each(x, "@title") do |ttl|
46
+ out << ttl.to_s.spacify
47
+ # p [gi, out.last]
48
+ end
49
+ gi1 = if gi == "texttable"; "table" else gi end
50
+ if out == [] # nameless
51
+ # nameless, anchorless fig doesn't get a number; ignore
52
+ next if gi == "figure" && !ref
53
+ # Synthesize name (if not redundant)
54
+ out = ["#{gi1.capitalize} #{lists[gi1].size + 1}"] if !ref
55
+ end
56
+ # p [gi, out]
57
+ lists[gi1] << [ref, out.join(" ")]
58
+ end
59
+
60
+ lists.each do |k, v|
61
+ title = "List of #{k.capitalize}s"
62
+ case target
63
+ when :note
64
+ puts
65
+ puts "--- note_#{title.gsub(" ", "_")}"
66
+ puts
67
+ when :section
68
+ puts
69
+ puts "# #{title}"
70
+ puts "{:unnumbered}"
71
+ else
72
+ fail
73
+ end
74
+ v.each_with_index do |(ref, ti), n|
75
+ ti = "[#{ti}](##{ref})" if ref
76
+ puts "#{n+1}. #{ti}"
77
+ end
78
+ end
data/bin/kramdown-rfc-lsr CHANGED
@@ -79,6 +79,15 @@ end
79
79
 
80
80
  doc = REXML::Document.new(xml)
81
81
 
82
+ REXML::XPath.match(doc.root, '//xi:include').each do |el|
83
+ begin
84
+ refdoc = REXML::Document.new(URI(el[:href]).open.read)
85
+ el.replace_with(refdoc.root)
86
+ rescue => e
87
+ warn "*** error getting xinclude #{el} resolved: #{e}"
88
+ end
89
+ end
90
+
82
91
  def series_info_to_URI(si)
83
92
  case si[:name]
84
93
  when "RFC"
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.7.19'
3
+ s.version = '1.7.21'
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.}
@@ -14,11 +14,23 @@ spec = Gem::Specification.new do |s|
14
14
  s.add_dependency('net-http-persistent', '~> 4.0')
15
15
  s.add_dependency('differ', '~> 0.1')
16
16
  s.add_dependency('base64', '>= 0.1')
17
- s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/echars bin/kramdown-rfc-extract-markdown bin/kramdown-rfc-extract-sourcecode bin/kramdown-rfc-lsr 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 bin/kramdown-rfc-clean-svg-ids)
17
+ s.files = Dir['lib/**/*.rb'] +
18
+ %w(README.md LICENSE kramdown-rfc2629.gemspec
19
+ bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629
20
+ bin/doilit bin/echars bin/kramdown-rfc-extract-markdown
21
+ bin/kramdown-rfc-extract-sourcecode
22
+ bin/kramdown-rfc-extract-figures-tables
23
+ bin/kramdown-rfc-lsr data/kramdown-rfc2629.erb
24
+ data/encoding-fallbacks.txt data/math.json
25
+ bin/kramdown-rfc-cache-subseries-bibxml
26
+ bin/kramdown-rfc-autolink-iref-cleanup
27
+ bin/de-gfm
28
+ bin/kramdown-rfc-clean-svg-ids)
18
29
  s.require_path = 'lib'
19
30
  s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'echars',
20
31
  'kramdown-rfc-extract-markdown',
21
32
  'kramdown-rfc-extract-sourcecode',
33
+ 'kramdown-rfc-extract-figures-tables',
22
34
  'kramdown-rfc-lsr',
23
35
  'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
24
36
  'kramdown-rfc-cache-subseries-bibxml',
@@ -1306,9 +1306,16 @@ COLORS
1306
1306
  "#{XML_RESOURCE_ORG_PREFIX}/bibxml-rfcsubseries/#{name}"] # FOR NOW
1307
1307
  end
1308
1308
 
1309
+ KRAMDOWN_REFCACHETTL = (e = ENV["KRAMDOWN_REFCACHETTL"]) ? e.to_i : 3600
1310
+
1311
+ KRAMDOWN_REFCACHETTL_RFC = (e = ENV["KRAMDOWN_REFCACHETTL_RFC"]) ? e.to_i : 86400*7
1312
+ KRAMDOWN_REFCACHETTL_DOI_IANA = (e = ENV["KRAMDOWN_REFCACHETTL_DOI_IANA"]) ? e.to_i : 86400
1313
+ KRAMDOWN_REFCACHETTL_DOI = (e = ENV["KRAMDOWN_REFCACHETTL_DOI"]) ? e.to_i : KRAMDOWN_REFCACHETTL_DOI_IANA
1314
+ KRAMDOWN_REFCACHETTL_IANA = (e = ENV["KRAMDOWN_REFCACHETTL_IANA"]) ? e.to_i : KRAMDOWN_REFCACHETTL_DOI_IANA
1315
+
1309
1316
  # [subdirectory name, cache ttl in seconds, does it provide for ?anchor=]
1310
1317
  XML_RESOURCE_ORG_MAP = {
1311
- "RFC" => ["bibxml", 86400*7, false,
1318
+ "RFC" => ["bibxml", KRAMDOWN_REFCACHETTL_RFC, false,
1312
1319
  ->(fn, n){ [name = "reference.RFC.#{"%04d" % n.to_i}.xml",
1313
1320
  "https://bib.ietf.org/public/rfc/bibxml/#{name}"] }
1314
1321
  # was "https://www.rfc-editor.org/refs/bibxml/#{name}"] }
@@ -1317,10 +1324,10 @@ COLORS
1317
1324
  ->(fn, n){ [fn,
1318
1325
  "https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}.xml"] }
1319
1326
  ],
1320
- "BCP" => ["bibxml-rfcsubseries", 86400*7, false,
1327
+ "BCP" => ["bibxml-rfcsubseries", KRAMDOWN_REFCACHETTL_RFC, false,
1321
1328
  ->(fn, n){ Rfc2629::bcp_std_ref("BCP", n) }
1322
1329
  ],
1323
- "STD" => ["bibxml-rfcsubseries", 86400*7, false,
1330
+ "STD" => ["bibxml-rfcsubseries", KRAMDOWN_REFCACHETTL_RFC, false,
1324
1331
  ->(fn, n){ Rfc2629::bcp_std_ref("STD", n) }
1325
1332
  ],
1326
1333
  "W3C" => "bibxml4",
@@ -1336,9 +1343,10 @@ COLORS
1336
1343
  "NIST" => "bibxml2",
1337
1344
  "OASIS" => "bibxml2",
1338
1345
  "PKCS" => "bibxml2",
1339
- "DOI" => ["bibxml7", 86400, true, ->(fn, n){ ["computed-#{fn}", [:DOI, n] ] }, true # always_altproc
1346
+ "DOI" => ["bibxml7", KRAMDOWN_REFCACHETTL_DOI, true,
1347
+ ->(fn, n){ ["computed-#{fn}", [:DOI, n] ] }, true # always_altproc
1340
1348
  ], # emulate old 24 h cache
1341
- "IANA" => ["bibxml8", 86400, true], # ditto
1349
+ "IANA" => ["bibxml8", KRAMDOWN_REFCACHETTL_IANA, true], # ditto
1342
1350
  }
1343
1351
 
1344
1352
  # XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml.resource.org"
@@ -1348,8 +1356,6 @@ COLORS
1348
1356
  "https://#{XML_RESOURCE_ORG_HOST}/public/rfc"
1349
1357
  KRAMDOWN_USE_TOOLS_SERVER = ENV["KRAMDOWN_USE_TOOLS_SERVER"]
1350
1358
 
1351
- KRAMDOWN_REFCACHETTL = (e = ENV["KRAMDOWN_REFCACHETTL"]) ? e.to_i : 3600
1352
-
1353
1359
  KRAMDOWN_NO_TARGETS = ENV['KRAMDOWN_NO_TARGETS']
1354
1360
  KRAMDOWN_KEEP_TARGETS = ENV['KRAMDOWN_KEEP_TARGETS']
1355
1361
 
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.7.19
4
+ version: 1.7.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-30 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -161,6 +161,7 @@ executables:
161
161
  - echars
162
162
  - kramdown-rfc-extract-markdown
163
163
  - kramdown-rfc-extract-sourcecode
164
+ - kramdown-rfc-extract-figures-tables
164
165
  - kramdown-rfc-lsr
165
166
  - kdrfc
166
167
  - kramdown-rfc-cache-i-d-bibxml
@@ -182,6 +183,7 @@ files:
182
183
  - bin/kramdown-rfc-cache-i-d-bibxml
183
184
  - bin/kramdown-rfc-cache-subseries-bibxml
184
185
  - bin/kramdown-rfc-clean-svg-ids
186
+ - bin/kramdown-rfc-extract-figures-tables
185
187
  - bin/kramdown-rfc-extract-markdown
186
188
  - bin/kramdown-rfc-extract-sourcecode
187
189
  - bin/kramdown-rfc-lsr