kramdown-rfc2629 1.7.19 → 1.7.20

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: 2c12e9311998093f02e4531e98842dc02ade4b420dfdbef00703c4e3e9893c23
4
+ data.tar.gz: e2bf61b2ae0f91a9f446e1d4a173ac098574da66af92556264983b0a03b43597
5
5
  SHA512:
6
- metadata.gz: 5f9e4452395530cd215d5fa3f1c701cd393091424e25e42b564f26c55eb2e6d7601e5da7e87dee2cc6587041b960a76c0aa449277b4ac323b4dc4238a595d3af
7
- data.tar.gz: d7e408eca15365eb9b8c653dcd3f3dc78a040e6dc599a8e959e7e8ac59e0c630b196d716511ed345547aa5cc1707a1bf2af6a972d83dbeae3fa6ebbebc3ab8b1
6
+ metadata.gz: 49851614d829dc5b9f82f52c75d4e09028a2e5f9cd69ce763ab5a71f6116737f5051f70538bcf26a23506e117614574d8f6104858f1be17f2b639f71d8ca6e8e
7
+ data.tar.gz: 14db57344a965dee02bfac13b0fbfbcd516368737d32e029341ec3c7dcc0036c612219cac3336f3ee78d68e84340e4c815e0e1e3cd3f9c31de6f13ccf9bc8ca8
@@ -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.20'
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',
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.20
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-10-30 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