kramdown-rfc2629 1.6.28 → 1.6.29

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: 172e0d4fcfbb65449f29ffa7ca743ecf090a031638feaa355d8d5f7df10eca28
4
- data.tar.gz: 335e0852a920a3e9f3a8b5319a0328bcb49216a2bc6ba9dd1ce8c5e515759587
3
+ metadata.gz: 062a31f4914296fa8729f4256c83c79420950605b944076b923b836f6a982ced
4
+ data.tar.gz: d9a463cf4cbcc663bbd639b29c1641df308716d92b50b1add469bdc056937fad
5
5
  SHA512:
6
- metadata.gz: 446b0fb243297a7eff9231b43615ee06b389f9a7ab571f5699cf2527e4d062ed116caf5e9924c3a4fa842e2bfae82d47c2e9be68886c9be7005fbc23944cf326
7
- data.tar.gz: 14679cac5457fa6238a408e0547e27ce84d611af5d503db23aed52c76df1ef574f873cd13b467393e5e57111460c283f216c8b00c248c458b4b606e9d7455631
6
+ metadata.gz: 3cecb965efec5d1d40e0da6dee5a8389d45cc65f78a835cf756d979e9e836200b2ab80cd6fbd7686cd30bcd2cbf1beb08993a2615df049376705c8170e44dfc9
7
+ data.tar.gz: '056960710e1102ea0724d57774073c882411db9392f7c256c4ee5fe1c1e7118fa67a6518eeec87e4e456f92184e289c42479270144dcfdffda6b17d956902925'
@@ -2,47 +2,18 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  require 'rexml/document'
5
-
6
- SVG_NAMESPACES = {"svg"=>"http://www.w3.org/2000/svg",
7
- "xlink"=>"http://www.w3.org/1999/xlink"}
5
+ require 'kramdown-rfc/svg-id-cleanup'
8
6
 
9
7
  def svg_clean_ids(s)
10
8
  d = REXML::Document.new(s)
11
- d.context[:attribute_quote] = :quote # <-- Set double-quote as the attribute value delimiter
12
- gensym = "gensym000"
13
- REXML::XPath.each(d.root, "//svg:svg", SVG_NAMESPACES) do |x|
14
- gensym = gensym.succ
15
- # warn "*** SVG"
16
- # warn "*** SVG: #{x.to_s.size}"
17
- found_as_id = Set[]
18
- found_as_href = Set[]
19
- REXML::XPath.each(x, ".//*[@id]", SVG_NAMESPACES) do |y|
20
- # warn "*** ID: #{y}"
21
- name = y.attributes["id"]
22
- if found_as_id === name
23
- warn "*** duplicate ID #{name}"
24
- end
25
- found_as_id.add(name)
26
- y.attributes["id"] = "#{name}-#{gensym}"
27
- end
28
- REXML::XPath.each(x, ".//*[@xlink:href]", SVG_NAMESPACES) do |y|
29
- # warn "*** HREF: #{y}"
30
- name = y.attributes["href"]
31
- name1 = name[1..-1]
32
- if !found_as_id === name1
33
- warn "*** unknown HREF #{name}"
34
- end
35
- found_as_href.add(name1)
36
- y.attributes["xlink:href"] = "#{name}-#{gensym}"
37
- end
38
- found_as_id -= found_as_href
39
- warn "*** warning: unused ID: #{found_as_id}" unless found_as_id.empty?
40
- end
9
+ d.context[:attribute_quote] = :quote # Set double-quote as the attribute value delimiter
10
+
11
+ svg_id_cleanup(d)
12
+
41
13
  d.to_s
42
14
  rescue => detail
43
15
  warn "*** Can't clean SVG: #{detail}"
44
- d
16
+ d.to_s
45
17
  end
46
18
 
47
- c = svg_clean_ids(ARGF.read)
48
- puts c.to_s
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.28'
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.}
@@ -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.28
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-04-07 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
@@ -181,6 +181,7 @@ files:
181
181
  - lib/kramdown-rfc/parameterset.rb
182
182
  - lib/kramdown-rfc/refxml.rb
183
183
  - lib/kramdown-rfc/rfc8792.rb
184
+ - lib/kramdown-rfc/svg-id-cleanup.rb
184
185
  - lib/kramdown-rfc2629.rb
185
186
  homepage: http://github.com/cabo/kramdown-rfc
186
187
  licenses: