kramdown-rfc2629 1.3.23 → 1.3.28

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: f07194d52bdfea697e714e5775fc5d668f153eb7bad63503ef7b582bf43c7e0b
4
- data.tar.gz: e92c7dc7adcf6a2cf45d234c382d7196e7b20fcfbbae650df0a7a0d341f8e0fc
3
+ metadata.gz: c6818d86a47ba8a06c199cdbca16a30644b06c4bb517fc7a5a5a35d93161a0e6
4
+ data.tar.gz: cb90602fd0b11b2e010200ffc4fac1727cd0aa446d2e59e5861d4fcd6b1cf579
5
5
  SHA512:
6
- metadata.gz: a20a4204e3b2b3bc571814508309857c6a4a0bea9fb66bf2424d9a08ce425cfc7ff8d9ab007ac51471a45e8916ae11c9e47a7b070386967e8def1eae24cb1b00
7
- data.tar.gz: 80cec91ada39501a454d92b02aa0f786293342272654d0758789feebcd27e0f7476b3607e985038887f0f44ea5c88b9f345d91c4e3fd778430617d98daf7e091
6
+ metadata.gz: b2c6ca51eaf892fb8b52c4bf115a82830deb1df21afcc0fb28c58eabbe273b727872be851d5e858c1018ce97e3ee5b8e7464086d4652a17af2f1144dda5f86a4
7
+ data.tar.gz: fb3125ce8ee03845999ad6f7e09cc9047ee4f4f3406da987c6a1458c0a4de65d0c2d590f62d02c516aa1d3de4d71e21660d33313fbf370452d57ee98d0a472ee
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.23'
3
+ s.version = '1.3.28'
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
 
@@ -128,6 +128,22 @@ module Kramdown
128
128
  end
129
129
 
130
130
  class Element
131
+
132
+ # Not fixing studly element names postalLine and seriesInfo yet
133
+
134
+ # occasionally regenerate the studly attribute name list via
135
+ # script in data/studly.rb
136
+ STUDLY_ATTR = %w(
137
+ asciiAbbrev asciiFullname asciiInitials asciiName asciiSurname
138
+ asciiValue blankLines derivedAnchor derivedContent derivedCounter
139
+ derivedLink displayFormat docName expiresDate hangIndent hangText
140
+ indexInclude iprExtract keepWithNext keepWithPrevious originalSrc
141
+ prepTime quoteTitle quotedFrom removeInRFC sectionFormat seriesNo
142
+ showOnFrontPage slugifiedName sortRefs submissionType symRefs tocDepth
143
+ tocInclude
144
+ )
145
+ STUDLY_ATTR_MAP = Hash[STUDLY_ATTR.map {|s| [s.downcase, s]}]
146
+
131
147
  def rfc2629_fix
132
148
  if a = attr
133
149
  if anchor = a.delete('id')
@@ -136,6 +152,11 @@ module Kramdown
136
152
  if anchor = a.delete('href')
137
153
  a['target'] = anchor
138
154
  end
155
+ attr.keys.each do |k|
156
+ if (d = k.gsub(/_(.|$)/) { $1.upcase }) != k or d = STUDLY_ATTR_MAP[k]
157
+ a[d] = a.delete(k)
158
+ end
159
+ end
139
160
  end
140
161
  end
141
162
  end
@@ -268,7 +289,12 @@ COLORS
268
289
  REXML::XPath.each(d.root, "//*[@fill]") { |x| x.attributes["fill"] = svg_munch_color(x.attributes["fill"], true) }
269
290
  REXML::XPath.each(d.root, "//*[@id]") { |x| x.attributes["id"] = svg_munch_id(x.attributes["id"]) }
270
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 }
271
294
  d.to_s
295
+ rescue => detail
296
+ warn "*** Can't clean SVG: #{detail}"
297
+ d
272
298
  end
273
299
 
274
300
  def memoize(meth, *args)
@@ -309,13 +335,13 @@ COLORS
309
335
  when "mermaid"
310
336
  result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
311
337
  outpath = file.path + ".svg"
312
- result1 = File.read(outpath)
313
- File.unlink(outpath)
338
+ result1 = File.read(outpath) rescue '' # don't die before providing error message
339
+ File.unlink(outpath) rescue nil # ditto
314
340
  when "plantuml", "plantuml-utxt"
315
341
  plantuml = "@startuml\n#{result}\n@enduml"
316
342
  result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
317
343
  result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
318
- err << err1
344
+ err << err1.to_s
319
345
  when "math"
320
346
  result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
321
347
  result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
@@ -328,6 +354,10 @@ COLORS
328
354
  result1, err, _s = Open3.capture3("svgcheck -qa", stdin_data: result1);
329
355
  capture_croak("svgcheck", err)
330
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
331
361
  [result, result1] # text, svg
332
362
  end
333
363
 
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.23
4
+ version: 1.3.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-21 00:00:00.000000000 Z
11
+ date: 2021-02-05 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
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  requirements: []
100
- rubygems_version: 3.1.4
101
+ rubygems_version: 3.2.3
101
102
  signing_key:
102
103
  specification_version: 4
103
104
  summary: Kramdown extension for generating RFC 7749 XML.