kramdown-rfc2629 1.3.24 → 1.3.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: 4917395db5dce706708b9a3ce81da25a4089d0982b6f6c577fe2249248718f3c
4
- data.tar.gz: c2c3a7ce6d9269674a20dcbd793e2bd0f451cee98fa36dbe5b2be47b29d76f30
3
+ metadata.gz: 0e453f1845b6d5384b372a0e934068226afe4d2241c7f0b16bf0bd4efc216ef8
4
+ data.tar.gz: 9e2d8c085ad1c78a95347843650b5d47f05872108ac7d93a91e6eaad62285e0a
5
5
  SHA512:
6
- metadata.gz: 3818e58468fef81b14fb7bf7e399a0ba740ed08a3b2e2b98a0e4e2019c536a456aec5678e1e3a6a525800d236a245bd86f05bf07610048c287f72c633cb1355d
7
- data.tar.gz: 884d1d3650106e695294dfdf96a534db6e1f40fd7204e10bfab118fc50ebca1db65b28762d52c57884732f65da37183c83a34834cbad21a6c9a1f77db6f7e023
6
+ metadata.gz: 52d76611fd7500af5b0d688e43b858d0d97a83c0e0cba73ef42d5cb076f922be008fc7c2a053a77bbbf0c11465038891f1c07d823f6d2675918adb5708e4f0d0
7
+ data.tar.gz: 44aa98da4b6e6d263d77865a7d2335d64320ce4422ecac139c61f5f060acd47781f8bac49197c938e2ccf97dfe4c8ebf23770eaf503cd3422e77b27ce9752002
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
data/bin/kramdown-rfc2629 CHANGED
@@ -4,7 +4,7 @@ require 'kramdown-rfc2629'
4
4
  require 'kramdown-rfc/parameterset'
5
5
  require 'kramdown-rfc/refxml'
6
6
  require 'yaml'
7
- require 'erb'
7
+ require 'kramdown-rfc/erb'
8
8
  require 'date'
9
9
 
10
10
  # try to get this from gemspec.
@@ -154,7 +154,7 @@ def xml_from_sections(input)
154
154
  if bibref
155
155
  if old = anchor_to_bibref[word]
156
156
  if bibref != old
157
- warn "*** conflicting definitions for xref #{anchor}: #{old} != #{bibref}"
157
+ warn "*** conflicting definitions for xref #{word}: #{old} != #{bibref}"
158
158
  end
159
159
  else
160
160
  anchor_to_bibref[word] = bibref
@@ -229,7 +229,7 @@ def xml_from_sections(input)
229
229
 
230
230
  erbfilename = File.expand_path '../../data/kramdown-rfc2629.erb', __FILE__
231
231
  erbfile = File.read(erbfilename, coding: "UTF-8")
232
- erb = ERB.new(erbfile, nil, '-')
232
+ erb = ERB.trim_new(erbfile, '-')
233
233
  # remove redundant nomarkdown pop outs/pop ins as they confuse kramdown
234
234
  input = erb.result(binding).gsub(%r"{::nomarkdown}\s*{:/nomarkdown}"m, "")
235
235
  ps.warn_if_leftovers
@@ -1,12 +1,12 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.24'
3
+ s.version = '1.3.29'
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']
@@ -0,0 +1,16 @@
1
+ require 'erb'
2
+
3
+ class ERB
4
+
5
+ case version.sub("erb.rb [", "")
6
+ when /\A2.1/ # works back to 1.9.1
7
+ def self.trim_new(s, trim)
8
+ ERB.new(s, nil, trim)
9
+ end
10
+ else
11
+ def self.trim_new(s, trim)
12
+ ERB.new(s, trim_mode: trim)
13
+ end
14
+ end
15
+
16
+ end
@@ -1,3 +1,5 @@
1
+ require 'kramdown-rfc/erb'
2
+
1
3
  module KramdownRFC
2
4
 
3
5
  extend Kramdown::Utils::Html
@@ -8,7 +10,7 @@ module KramdownRFC
8
10
 
9
11
  def self.ref_to_xml(k, v)
10
12
  vps = KramdownRFC::ParameterSet.new(v)
11
- erb = ERB.new <<-REFERB, nil, '-'
13
+ erb = ERB.trim_new <<-REFERB, '-'
12
14
  <reference anchor="<%= escattr(k) %>" <%= vps.attr("target") %>>
13
15
  <front>
14
16
  <%= vps.ele("title") -%>
@@ -75,7 +77,7 @@ module KramdownRFC
75
77
  ERB
76
78
 
77
79
  def self.person_element_from_aups(element_name, aups)
78
- erb = ERB.new(PERSON_ERB, nil, '-')
80
+ erb = ERB.trim_new(PERSON_ERB, '-')
79
81
  erb.result(binding)
80
82
  end
81
83
 
@@ -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
 
@@ -778,10 +787,10 @@ COLORS
778
787
  ttl ||= KRAMDOWN_REFCACHETTL # everything but RFCs might change a lot
779
788
  puts "*** Huh: #{fn}" unless sub
780
789
  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"
784
- end
790
+ # if can_anchor # create anchor server-side for stand_alone: false
791
+ # url << "?anchor=#{anchor}"
792
+ # fn[/.xml$/] = "--anchor=#{anchor}.xml"
793
+ # end
785
794
  to_insert = get_and_cache_resource(url, fn.gsub('/', '_'), ttl)
786
795
  to_insert.scrub! rescue nil # only do this for Ruby >= 2.1
787
796
  # 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.24
4
+ version: 1.3.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: 2021-01-01 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
  - - "~>"
@@ -74,6 +74,7 @@ files:
74
74
  - data/kramdown-rfc2629.erb
75
75
  - data/math.json
76
76
  - kramdown-rfc2629.gemspec
77
+ - lib/kramdown-rfc/erb.rb
77
78
  - lib/kramdown-rfc/gzip-clone.rb
78
79
  - lib/kramdown-rfc/parameterset.rb
79
80
  - lib/kramdown-rfc/refxml.rb