kramdown-rfc2629 1.3.25 → 1.3.30

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: 4a18c9460f832be1f0bb626cc1b6ea385a6535b7af585212ec0c961ae1945d36
4
- data.tar.gz: f34512123c073979fff13351c1fdd3ec640376a604e9aba7e849652d59172023
3
+ metadata.gz: 450d01ba97272a13529eebbfacb09eeca5bc2ab11ca5e62ffbb030283fe27d46
4
+ data.tar.gz: 1c8662ed374b3b5de9977d84600c71ebe95ff58844270fe40048a85e5b04eb17
5
5
  SHA512:
6
- metadata.gz: 69f0328719872f0bef0d81bffb5fa495e384f599a0fb3843cc4c9d6065811be71f21e7ab9700cb1d1f3419d5a91dc88af62c855b5f97f499519b15b11f888bef
7
- data.tar.gz: 56778f5ec4e581ac21d17637c1098924ccd6a0b97facd12a2e636fdae755798c6ce7a545e5b8395ec17168e9e118230c1cca00e23ab8332eedbca6a0cf57dccc
6
+ metadata.gz: 79145499d9ee1c7a8596d730956175c28278e8b66d011aa37a1797c043104abba756b3e37b4a69b19b687603530d7ae980ccaace45444614e272ec7e522c4c0d
7
+ data.tar.gz: f1acecfe30457df4f7c4a8e9083a29b7d9d17fd26a971a960e295ceabbbc72019529e5422af71c83bea76d1abc25d187d6cb69b6bf15342ac3ee19d52197685d
data/README.md CHANGED
@@ -294,13 +294,24 @@ output generated by the tool (e.g., `plantuml-utxt`).
294
294
 
295
295
  Currently supported labels as of 1.3.9:
296
296
 
297
- * goat, ditaa: ASCII (plaintext) art to figure conversion
298
- * mscgen: Message Sequence Charts
299
- * plantuml: widely used multi-purpose diagram generator
297
+ * [goat][], [ditaa][]: ASCII (plaintext) art to figure conversion
298
+ * [mscgen][]: Message Sequence Charts
299
+ * [plantuml][]: widely used multi-purpose diagram generator
300
300
  * plantuml-utxt: Like plantuml, except that a plantuml-generated
301
301
  plaintext form is used
302
- * mermaid: Very experimental; the conversion to SVG is prone to
302
+ * [mermaid][]: Very experimental; the conversion to SVG is prone to
303
303
  generate black-on-black text in this version
304
+ * math: display math using [tex2svg][] for HTML/PDF and [asciitex][]
305
+ (fork: [asciiTeX][asciiTeX-eggert]) for plaintext
306
+
307
+ [goat]: https://github.com/blampe/goat
308
+ [ditaa]: https://github.com/stathissideris/ditaa
309
+ [mscgen]: http://www.mcternan.me.uk/mscgen/
310
+ [plantuml]: https://plantuml.com
311
+ [mermaid]: https://github.com/mermaid-js/mermaid-cli
312
+ [tex2svg]: https://github.com/mathjax/MathJax-demos-node/blob/master/direct/tex2svg
313
+ [asciitex]: http://asciitex.sourceforge.net/
314
+ [asciiTeX-eggert]: https://github.com/larseggert/asciiTeX
304
315
 
305
316
  Note that this feature does not play well with the CI (continuous
306
317
  integration) support in Martin Thomson's [I-D Template][], as that may
data/bin/kdrfc CHANGED
@@ -24,6 +24,12 @@ def process_mkd(input, output)
24
24
  end
25
25
  end
26
26
 
27
+ def run_idnits(txt_fn)
28
+ unless system("idnits", txt_fn)
29
+ warn "*** problem #$? running idnits"
30
+ end
31
+ end
32
+
27
33
  def process_xml(*args)
28
34
  if $options.remote
29
35
  process_xml_remotely(*args)
@@ -124,6 +130,9 @@ BANNER
124
130
  opts.on("-c", "--[no-]convert", "Convert xml to v3 xml") do |v|
125
131
  $options.v2v3 = v
126
132
  end
133
+ opts.on("-i", "--[no-]idnits", "Run idnits on the resulting text") do |v|
134
+ $options.idnits = v
135
+ end
127
136
  opts.on("-h", "--[no-]html", "Convert to html as well") do |v|
128
137
  $options.html = v
129
138
  end
@@ -139,8 +148,9 @@ op.parse!
139
148
  def process_the_xml(fn, base)
140
149
  process_xml(fn, "#{base}.prepped.xml", "--preptool") if $options.prep
141
150
  process_xml(fn, "#{base}.v2v3.xml", "--v2v3") if $options.v2v3
142
- process_xml(fn, "#{base}.txt") if $options.txt
151
+ process_xml(fn, "#{base}.txt") if $options.txt || $options.idnits
143
152
  process_xml(fn, "#{base}.html", "--html") if $options.html
153
+ run_idnits("#{base}.txt") if $options.idnits
144
154
  end
145
155
 
146
156
  case ARGV.size
@@ -1,12 +1,12 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.25'
3
+ s.version = '1.3.30'
4
4
  s.summary = "Kramdown extension for generating RFC 7749 XML."
5
5
  s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
6
6
  "kramdown" markdown parser. Mostly useful for RFC writers.}
7
7
  s.add_dependency('kramdown', '~> 1.17.0')
8
8
  s.add_dependency('certified', '~> 1.0')
9
- s.add_dependency('json', '~> 2.0')
9
+ s.add_dependency('json_pure', '~> 2.0')
10
10
  s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json)
11
11
  s.require_path = 'lib'
12
12
  s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown', 'kdrfc']
@@ -289,7 +289,12 @@ COLORS
289
289
  REXML::XPath.each(d.root, "//*[@fill]") { |x| x.attributes["fill"] = svg_munch_color(x.attributes["fill"], true) }
290
290
  REXML::XPath.each(d.root, "//*[@id]") { |x| x.attributes["id"] = svg_munch_id(x.attributes["id"]) }
291
291
  ## REXML::XPath.each(d.root, "//rect") { |x| x.attributes["style"] = "fill:none;stroke:black;stroke-width:1" unless x.attributes["style"] }
292
+ # Fix for mermaid:
293
+ REXML::XPath.each(d.root, "//polygon") { |x| x.attributes["rx"] = nil; x.attributes["ry"] = nil }
292
294
  d.to_s
295
+ rescue => detail
296
+ warn "*** Can't clean SVG: #{detail}"
297
+ d
293
298
  end
294
299
 
295
300
  def memoize(meth, *args)
@@ -330,13 +335,13 @@ COLORS
330
335
  when "mermaid"
331
336
  result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
332
337
  outpath = file.path + ".svg"
333
- result1 = File.read(outpath)
334
- File.unlink(outpath)
338
+ result1 = File.read(outpath) rescue '' # don't die before providing error message
339
+ File.unlink(outpath) rescue nil # ditto
335
340
  when "plantuml", "plantuml-utxt"
336
341
  plantuml = "@startuml\n#{result}\n@enduml"
337
342
  result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
338
343
  result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
339
- err << err1
344
+ err << err1.to_s
340
345
  when "math"
341
346
  result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
342
347
  result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
@@ -349,6 +354,10 @@ COLORS
349
354
  result1, err, _s = Open3.capture3("svgcheck -qa", stdin_data: result1);
350
355
  capture_croak("svgcheck", err)
351
356
  # warn ["svgcheck:", result1.inspect]
357
+ if result1 == ''
358
+ warn "*** could not create svg for #{result.inspect[0...20]}..."
359
+ exit 65 # EX_DATAERR
360
+ end
352
361
  [result, result1] # text, svg
353
362
  end
354
363
 
@@ -686,7 +695,7 @@ COLORS
686
695
  message = "fetching"
687
696
  fetch_timeout = 60 # seconds; long timeout needed for Travis
688
697
  end
689
- $stderr.puts "#{fn}: #{message}"
698
+ $stderr.puts "#{fn}: #{message} from #{url}"
690
699
  if ENV["HAVE_WGET"]
691
700
  `cd #{REFCACHEDIR}; wget -t 3 -T #{fetch_timeout} -Nnv "#{url}"` # ignore errors if offline (hack)
692
701
  begin
@@ -730,8 +739,12 @@ COLORS
730
739
 
731
740
  # [subdirectory name, cache ttl in seconds, does it provide for ?anchor=]
732
741
  XML_RESOURCE_ORG_MAP = {
733
- "RFC" => ["bibxml", 86400*7], # these should change rarely
734
- "I-D" => "bibxml3",
742
+ "RFC" => ["bibxml", 86400*7, false,
743
+ ->(fn, n){ "https://www.rfc-editor.org/refs/bibxml/#{fn}"}
744
+ ],
745
+ "I-D" => ["bibxml3", false, false,
746
+ ->(fn, n){ "https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}/xml" }
747
+ ],
735
748
  "W3C" => "bibxml4",
736
749
  "3GPP" => "bibxml5",
737
750
  "ANSI" => "bibxml2",
@@ -752,6 +765,7 @@ COLORS
752
765
  XML_RESOURCE_ORG_HOST = ENV["XML_RESOURCE_ORG_HOST"] || "xml2rfc.tools.ietf.org"
753
766
  XML_RESOURCE_ORG_PREFIX = ENV["XML_RESOURCE_ORG_PREFIX"] ||
754
767
  "https://#{XML_RESOURCE_ORG_HOST}/public/rfc"
768
+ KRAMDOWN_USE_TOOLS_SERVER = ENV["KRAMDOWN_USE_TOOLS_SERVER"]
755
769
 
756
770
  KRAMDOWN_REFCACHETTL = (e = ENV["KRAMDOWN_REFCACHETTL"]) ? e.to_i : 3600
757
771
 
@@ -774,14 +788,18 @@ COLORS
774
788
  to_insert = ""
775
789
  src.scan(/(W3C|3GPP|[A-Z-]+)[.]?([A-Za-z_0-9.\/\+-]+)/) do |t, n|
776
790
  fn = "reference.#{t}.#{n}.xml"
777
- sub, ttl, can_anchor = XML_RESOURCE_ORG_MAP[t]
791
+ sub, ttl, can_anchor, altproc = XML_RESOURCE_ORG_MAP[t]
778
792
  ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
779
793
  puts "*** Huh: #{fn}" unless sub
780
- url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
781
- if can_anchor # create anchor server-side for stand_alone: false
782
- url << "?anchor=#{anchor}"
783
- fn[/.xml$/] = "--anchor=#{anchor}.xml"
794
+ if altproc && !KRAMDOWN_USE_TOOLS_SERVER
795
+ url = altproc.call(fn, n)
796
+ else
797
+ url = "#{XML_RESOURCE_ORG_PREFIX}/#{sub}/#{fn}"
784
798
  end
799
+ # if can_anchor # create anchor server-side for stand_alone: false
800
+ # url << "?anchor=#{anchor}"
801
+ # fn[/.xml$/] = "--anchor=#{anchor}.xml"
802
+ # end
785
803
  to_insert = get_and_cache_resource(url, fn.gsub('/', '_'), ttl)
786
804
  to_insert.scrub! rescue nil # only do this for Ruby >= 2.1
787
805
  # this may be a bit controversial: Don't break the build if reference is broken
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.3.25
4
+ version: 1.3.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: json
42
+ name: json_pure
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"