kramdown-rfc2629 1.7.35 → 1.7.36

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: db828f3c40e956c5cf30f1c29cf658784bac36c2af464cf0216ef8fa14434d71
4
- data.tar.gz: '09516f03f56523d7636f14689b15975417f9ce10cf8fd6f980cf844af003c945'
3
+ metadata.gz: a9ff7213b94221a765a71330807020f096d5359482a00597494a7b7ac947a3ab
4
+ data.tar.gz: c9950dd8e71d8dcd45d128a1ef505c10336ce66fba9a790e4db4db114902e02c
5
5
  SHA512:
6
- metadata.gz: 0da3a29b338f0a3ce60e54b9dae53cfd6568e75e0320c256a716728ec099e0f8b60a819f0f6c210f3c14b1c81a74d981cbe6f30c42d1b1f5ca315f0f690f6301
7
- data.tar.gz: a2af7e2f8f79cc46dd0ff426c90457d8543b99be587e8defde3bc7b824ee3afa25feaef98b33cb4777e20ae3fb1de9cb9b9a872d53736852e0d5cc137d1217ca
6
+ metadata.gz: df87cfdc51a33bdc89a67723a66f475671d29d71ace9796bd2698135ee4b99e3a62072a0412ec9c0773b202790beae1a8d8ad10d7c8c41dd43c0a57812973018
7
+ data.tar.gz: 1c4de95e1f2dffdac9faff39ed32853cf36ae072ee6bdb447c8ce87f74203ca24165e391d1ee5fe92bc49ecc20ae6abf57a44d6cb26917e33096b9156528f7a1
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.7.35'
3
+ s.version = '1.7.36'
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.}
@@ -192,8 +192,12 @@ NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
192
192
 
193
193
  NORMINFORM = { "!" => :normative, "?" => :informative }
194
194
 
195
- def yaml_load(input, *args)
196
- begin
195
+
196
+ # Handle several transitions of YAML API:
197
+ # * very early Ruby (no safe_load, before Ruby 2.1)
198
+ # * Ruby before 3.1 (safe_load, positional parameters)
199
+ # * Ruby 2.6 up (safe_load, keyword parameters)
200
+ def yaml_load_compat(input, *args)
197
201
  if YAML.respond_to?(:safe_load)
198
202
  begin
199
203
  YAML.safe_load(input, *args)
@@ -203,10 +207,25 @@ def yaml_load(input, *args)
203
207
  else
204
208
  YAML.load(input)
205
209
  end
206
- rescue Psych::SyntaxError => e
207
- warn "*** YAML syntax error: #{e}"
208
- exit 65 # EX_DATAERR
209
- end
210
+ end
211
+
212
+ def yaml_diagnose(input, *args)
213
+ l = input.lines.to_a
214
+ (l.size-1).downto(0) do |nl|
215
+ yaml_load_compat(l[0...nl].join, *args) rescue next
216
+ warn "** YAML appears to be parsable up to line #{nl}"
217
+ return
218
+ end
219
+ end
220
+
221
+ def yaml_load(input, *args)
222
+ begin
223
+ yaml_load_compat(input, *args)
224
+ rescue Psych::SyntaxError => e
225
+ warn "*** YAML syntax error: #{e}"
226
+ yaml_diagnose(input, *args) rescue nil
227
+ exit 65 # EX_DATAERR
228
+ end
210
229
  end
211
230
 
212
231
  def process_kramdown_options(coding_override = nil,
@@ -303,13 +322,13 @@ def xml_from_sections(input)
303
322
  # the first section is a YAML with front matter parameters (don't put a label here)
304
323
  # We put back the "---" plus gratuitous blank lines to hack the line number in errors
305
324
  yaml_in = input[/---\s*/] << sections.shift[2]
325
+ ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
306
326
  begin
307
327
  require 'kramdown-rfc/yamlcheck'
308
328
  KramdownRFC::YAMLcheck.check_dup_keys(yaml_in)
309
329
  rescue => e
310
330
  warn "** Cannot check for duplicate keys in YAML header (#{e})"
311
331
  end
312
- ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
313
332
 
314
333
  if v = ps[:v]
315
334
  warn "*** unsupported RFCXML version #{v}" if v != 3
@@ -745,7 +745,7 @@ COLORS
745
745
  "<![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]>")
746
746
  if result1 # nest TXT in artset with SVG
747
747
  retsvg = mk_artwork(artwork_attr, "svg",
748
- result1.sub(/.*?<svg/m, "<svg"))
748
+ result1.sub(/.*?<svg/m, "<svg")) # , t == "mermaid")
749
749
  retart = "<artset>#{retsvg}#{retart}</artset>"
750
750
  end
751
751
  "#{' '*indent}<figure#{el_html_attributes(el)}>#{retart}</figure>\n"
@@ -844,8 +844,14 @@ COLORS
844
844
  result
845
845
  end
846
846
 
847
- def mk_artwork(artwork_attr, typ, content)
848
- "<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
847
+ def mk_artwork(artwork_attr, typ, content, use_data = false)
848
+ if use_data
849
+ warn "** using data URI for artwork type #{typ}"
850
+ data = %{data:application/octet-stream;base64,#{[content].pack('m0')}}
851
+ "<artwork #{html_attributes(artwork_attr.merge("type" => typ, "src" => data))}></artwork>"
852
+ else
853
+ "<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
854
+ end
849
855
  end
850
856
 
851
857
  def convert_blockquote(el, indent, opts)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.35
4
+ version: 1.7.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubygems_version: 4.0.2
227
+ rubygems_version: 4.0.8
228
228
  specification_version: 4
229
229
  summary: Kramdown extension for generating RFCXML (RFC 799x).
230
230
  test_files: []