kramdown-rfc2629 1.6.27 → 1.6.29

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7debb198a9e9bf5c199901337cdaa69059c72345a83c18092aaa24bbc1b533b7
4
- data.tar.gz: c321ce924e845f46ded79a23b1ffbc8bee52e6fb6352ec49e332b94fd63e8b1e
3
+ metadata.gz: 062a31f4914296fa8729f4256c83c79420950605b944076b923b836f6a982ced
4
+ data.tar.gz: d9a463cf4cbcc663bbd639b29c1641df308716d92b50b1add469bdc056937fad
5
5
  SHA512:
6
- metadata.gz: 36ea96fc6d606198c451fc2fab24cf50a8472a099380c5ff82b6326aa924e55b3a3e51b9180210dd4caf97e57a8aad0c6652e12c8cd05d814b32b5511f969e25
7
- data.tar.gz: 025bc51c6061f60e258f512a0a5c10710da45083408a16135ffa6d4f234e412cabc8b17e8ce98bd913ccfb5c97869a02084400d9c9917df3e49b08c7a2016c6a
6
+ metadata.gz: 3cecb965efec5d1d40e0da6dee5a8389d45cc65f78a835cf756d979e9e836200b2ab80cd6fbd7686cd30bcd2cbf1beb08993a2615df049376705c8170e44dfc9
7
+ data.tar.gz: '056960710e1102ea0724d57774073c882411db9392f7c256c4ee5fe1c1e7118fa67a6518eeec87e4e456f92184e289c42479270144dcfdffda6b17d956902925'
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'rexml/document'
5
+ require 'kramdown-rfc/svg-id-cleanup'
6
+
7
+ def svg_clean_ids(s)
8
+ d = REXML::Document.new(s)
9
+ d.context[:attribute_quote] = :quote # Set double-quote as the attribute value delimiter
10
+
11
+ svg_id_cleanup(d)
12
+
13
+ d.to_s
14
+ rescue => detail
15
+ warn "*** Can't clean SVG: #{detail}"
16
+ d.to_s
17
+ end
18
+
19
+ puts svg_clean_ids(ARGF.read)
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.6.27'
3
+ s.version = '1.6.29'
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.}
@@ -13,14 +13,15 @@ spec = Gem::Specification.new do |s|
13
13
  s.add_dependency('unicode-scripts', '~> 1.0')
14
14
  s.add_dependency('net-http-persistent', '~> 4.0')
15
15
  s.add_dependency('differ', '~>0.1')
16
- 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 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)
16
+ 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 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
17
  s.require_path = 'lib'
18
18
  s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'echars',
19
19
  'kramdown-rfc-extract-markdown',
20
20
  'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
21
21
  'kramdown-rfc-cache-subseries-bibxml',
22
22
  'kramdown-rfc-autolink-iref-cleanup',
23
- 'de-gfm']
23
+ 'de-gfm',
24
+ 'kramdown-rfc-clean-svg-ids']
24
25
  s.required_ruby_version = '>= 2.3.0'
25
26
  # s.requirements = 'wget'
26
27
  # s.has_rdoc = true
@@ -262,6 +262,9 @@ def xml_from_sections(input)
262
262
  if o = ps[:'autolink-iref-cleanup']
263
263
  $options.autolink_iref_cleanup = o
264
264
  end
265
+ if o = ps[:'svg-id-cleanup']
266
+ $options.svg_id_cleanup = o
267
+ end
265
268
 
266
269
  coding_override = ps.has(:coding)
267
270
  smart_quotes = ps[:smart_quotes]
@@ -579,12 +582,23 @@ if $options.v3_used && !$options.v3
579
582
  $options.v3 = true
580
583
  end
581
584
 
582
- if $options.autolink_iref_cleanup
585
+ # only reparse output document if cleanup actions required
586
+ if $options.autolink_iref_cleanup || $options.svg_id_cleanup
583
587
  require 'rexml/document'
584
- require 'kramdown-rfc/autolink-iref-cleanup'
585
588
 
586
589
  d = REXML::Document.new(output)
587
- autolink_iref_cleanup(d)
590
+ d.context[:attribute_quote] = :quote # Set double-quote as the attribute value delimiter
591
+
592
+ if $options.autolink_iref_cleanup
593
+ require 'kramdown-rfc/autolink-iref-cleanup'
594
+ autolink_iref_cleanup(d)
595
+ end
596
+
597
+ if $options.svg_id_cleanup
598
+ require 'kramdown-rfc/svg-id-cleanup'
599
+ svg_id_cleanup(d)
600
+ end
601
+
588
602
  output = d.to_s
589
603
  end
590
604
 
@@ -0,0 +1,39 @@
1
+ require 'rexml/document'
2
+
3
+ SVG_NAMESPACES = {"svg"=>"http://www.w3.org/2000/svg",
4
+ "xlink"=>"http://www.w3.org/1999/xlink"}
5
+
6
+ def svg_id_cleanup(d)
7
+ gensym = "gensym000"
8
+
9
+ REXML::XPath.each(d.root, "//svg:svg", SVG_NAMESPACES) do |x|
10
+ gensym = gensym.succ
11
+ # warn "*** SVG"
12
+ # warn "*** SVG: #{x.to_s.size}"
13
+ found_as_id = Set[]
14
+ found_as_href = Set[]
15
+ REXML::XPath.each(x, ".//*[@id]", SVG_NAMESPACES) do |y|
16
+ # warn "*** ID: #{y}"
17
+ name = y.attributes["id"]
18
+ if found_as_id === name
19
+ warn "*** duplicate ID #{name}"
20
+ end
21
+ found_as_id.add(name)
22
+ y.attributes["id"] = "#{name}-#{gensym}"
23
+ end
24
+ REXML::XPath.each(x, ".//*[@xlink:href]", SVG_NAMESPACES) do |y|
25
+ # warn "*** HREF: #{y}"
26
+ name = y.attributes["href"]
27
+ name1 = name[1..-1]
28
+ if !found_as_id === name1
29
+ warn "*** unknown HREF #{name}"
30
+ end
31
+ found_as_href.add(name1)
32
+ y.attributes["xlink:href"] = "#{name}-#{gensym}"
33
+ end
34
+ found_as_id -= found_as_href
35
+ warn "*** warning: unused ID: #{found_as_id.to_a.join(", ")}" unless found_as_id.empty?
36
+ end
37
+ rescue => detail
38
+ warn "*** Can't clean SVG: #{detail}"
39
+ end
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.27
4
+ version: 1.6.29
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-03-18 00:00:00.000000000 Z
11
+ date: 2023-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -151,6 +151,7 @@ executables:
151
151
  - kramdown-rfc-cache-subseries-bibxml
152
152
  - kramdown-rfc-autolink-iref-cleanup
153
153
  - de-gfm
154
+ - kramdown-rfc-clean-svg-ids
154
155
  extensions: []
155
156
  extra_rdoc_files: []
156
157
  files:
@@ -164,6 +165,7 @@ files:
164
165
  - bin/kramdown-rfc-autolink-iref-cleanup
165
166
  - bin/kramdown-rfc-cache-i-d-bibxml
166
167
  - bin/kramdown-rfc-cache-subseries-bibxml
168
+ - bin/kramdown-rfc-clean-svg-ids
167
169
  - bin/kramdown-rfc-extract-markdown
168
170
  - bin/kramdown-rfc2629
169
171
  - data/encoding-fallbacks.txt
@@ -179,6 +181,7 @@ files:
179
181
  - lib/kramdown-rfc/parameterset.rb
180
182
  - lib/kramdown-rfc/refxml.rb
181
183
  - lib/kramdown-rfc/rfc8792.rb
184
+ - lib/kramdown-rfc/svg-id-cleanup.rb
182
185
  - lib/kramdown-rfc2629.rb
183
186
  homepage: http://github.com/cabo/kramdown-rfc
184
187
  licenses: