kramdown-rfc2629 1.5.13 → 1.5.14

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: 44da042356d9bc536e5c05d3256718ed025a7d83a1678fa66ee86078daeaf440
4
- data.tar.gz: 5ee1e04e156d30c36c070828f41ed382fb46a13a43310f8c6a2b5a597cb2fe4f
3
+ metadata.gz: 3097408dcedb58eab67f2de242d7ba51f8e62e82199e9da00b6a68ca0917c3dc
4
+ data.tar.gz: fbcac44963fb8a7ce2df22060e624410e8f7df4c439d2e7cdcc1fcb760f3b1c4
5
5
  SHA512:
6
- metadata.gz: 1ce55d74b92191986255d87e27f1891a4f60f7eb68fe4baff5ea0eedd264a76511870b5817bae23d6b76e553143621b9ab570c658cb6b197735c501b470cfc7a
7
- data.tar.gz: 8f044f904be1ef0f9d56bd430a7104d5e522b630cae07a318ef98c862639393350099148ecdb2dd1a3a027a2da627489aae1b7dcb64c1c9cbd60b7f56ca09541
6
+ metadata.gz: b79053e9e4a368ece939ef8a3cca6c8e72826dd0e35bee10a4cf1548f4e5b72d38fdf680a0ae33b17c33c24ab87335addd401d3df2d60b34476ccfb4f592a501
7
+ data.tar.gz: 0d1a39fbb8e26a5513deca8fdf9c844aed56cdcb27c02ab6695251bfadfbdd47721b0f3a90a2755171eb7eb58dc98629b57f8e528e0c7c00005f640a1d74bd6e
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.5.13'
3
+ s.version = '1.5.14'
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.}
@@ -447,59 +447,67 @@ COLORS
447
447
  end
448
448
  end
449
449
 
450
- def svg_tool_process(t, result)
450
+ def shell_prepare(opt)
451
+ " " << opt.shellsplit.shelljoin
452
+ end
453
+
454
+ DEFAULT_AASVG="aasvg --spaces=1"
455
+
456
+ def svg_tool_process(t, svg_opt, txt_opt, result)
451
457
  require 'tempfile'
452
458
  file = Tempfile.new("kramdown-rfc")
453
459
  file.write(result)
454
460
  file.close
455
461
  dont_clean = false
456
462
  dont_check = false
463
+ svg_opt = shell_prepare(svg_opt) if svg_opt
464
+ txt_opt = shell_prepare(txt_opt) if txt_opt
457
465
  case t
458
466
  when "protocol", "protocol-goat", "protocol-aasvg"
459
467
  cmdparm = result.lines.map(&:strip).select {|x| x != ''}.join(',')
460
- result, err, _s = Open3.capture3("protocol #{Shellwords.escape(cmdparm)}", stdin_data: '')
468
+ result, err, _s = Open3.capture3("protocol #{Shellwords.escape(cmdparm)}#{txt_opt}", stdin_data: '')
461
469
  if t == "protocol-goat"
462
470
  file.unlink
463
471
  file = Tempfile.new("kramdown-rfc")
464
472
  file.write(result)
465
473
  file.close
466
- result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
474
+ result1, err, _s = Open3.capture3("goat#{svg_opt} #{file.path}", stdin_data: result);
467
475
  dont_clean = true
468
476
  elsif t == "protocol-aasvg"
469
- result1, err, _s = Open3.capture3("aasvg", stdin_data: result);
477
+ result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
470
478
  dont_clean = true
471
479
  else
472
480
  result1 = nil
473
481
  end
474
482
  when "goat"
475
- result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
483
+ result1, err, _s = Open3.capture3("goat#{svg_opt} #{file.path}", stdin_data: result);
476
484
  dont_clean = true
477
485
  when "aasvg"
478
- result1, err, _s = Open3.capture3("aasvg", stdin_data: result);
486
+ result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
479
487
  dont_clean = true
480
488
  when "ditaa" # XXX: This needs some form of option-setting
481
- result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -", stdin_data: result);
489
+ result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -#{svg_opt}", stdin_data: result);
482
490
  when "mscgen"
483
- result1, err, _s = Open3.capture3("mscgen -T svg -i #{file.path} -o -", stdin_data: result);
491
+ result1, err, _s = Open3.capture3("mscgen -T svg -i #{file.path} -o -#{svg_opt}", stdin_data: result);
484
492
  when "mermaid"
485
- result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
493
+ result1, err, _s = Open3.capture3("mmdc -i #{file.path}#{svg_opt}", stdin_data: result); # -b transparent
486
494
  outpath = file.path + ".svg"
487
495
  result1 = File.read(outpath) rescue '' # don't die before providing error message
488
496
  File.unlink(outpath) rescue nil # ditto
489
497
  when "plantuml", "plantuml-utxt"
490
498
  plantuml = "@startuml\n#{result}\n@enduml"
491
- result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
492
- result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
499
+ result1, err, _s = Open3.capture3("plantuml -pipe -tsvg#{svg_opt}", stdin_data: plantuml);
500
+ result, err1, _s = Open3.capture3("plantuml -pipe -tutxt#{txt_opt}", stdin_data: plantuml) if t == "plantuml-utxt"
493
501
  err << err1.to_s
494
502
  when "railroad", "railroad-utf8"
495
- result1, err1, _s = Open3.capture3("kgt -l abnf -e svg", stdin_data: result);
503
+ result1, err1, _s = Open3.capture3("kgt -l abnf -e svg#{svg_opt}", stdin_data: result);
496
504
  result1 = svg_clean_kgt(result1); dont_clean = true
497
- result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}",
505
+ result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}#{txt_opt}",
498
506
  stdin_data: result);
499
507
  err << err1.to_s
500
508
  when "math"
501
- result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
502
- result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
509
+ result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false#{svg_opt} #{Shellwords.escape(' ' << result)}");
510
+ result, err1, _s = Open3.capture3("asciitex -f #{file.path}#{txt_opt}")
503
511
  err << err1
504
512
  end
505
513
  capture_croak(t, err)
@@ -576,12 +584,18 @@ COLORS
576
584
  if gi
577
585
  warn "*** Can't set GI #{gi} for composite SVG artset"
578
586
  end
579
- result, result1 = memoize(:svg_tool_process, t, result)
580
- if result1 # refactor!
581
- "#{' '*indent}<figure#{el_html_attributes(el)}><artset><artwork #{html_attributes(artwork_attr.merge("type"=> "svg"))}>#{result1.sub(/.*?<svg/m, "<svg")}</artwork><artwork #{html_attributes(artwork_attr.merge("type"=> "ascii-art"))}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></artset></figure>\n"
582
- else
583
- "#{' '*indent}<figure#{el_html_attributes(el)}><artwork #{html_attributes(artwork_attr.merge("type"=> "ascii-art"))}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></figure>\n"
587
+ result, result1 = memoize(:svg_tool_process, t,
588
+ artwork_attr.delete("svg-options"),
589
+ artwork_attr.delete("txt-options"),
590
+ result)
591
+ retart = mk_artwork(artwork_attr, "ascii-art",
592
+ "<![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]>")
593
+ if result1 # nest TXT in artset with SVG
594
+ retsvg = mk_artwork(artwork_attr, "svg",
595
+ result1.sub(/.*?<svg/m, "<svg"))
596
+ retart = "<artset>#{retsvg}#{retart}</artset>"
584
597
  end
598
+ "#{' '*indent}<figure#{el_html_attributes(el)}>#{retart}</figure>\n"
585
599
  else
586
600
  gi ||= (
587
601
  if !$options.v3 || !t || ARTWORK_TYPES.include?(t) || artwork_attr["align"]
@@ -595,6 +609,10 @@ COLORS
595
609
  end
596
610
  end
597
611
 
612
+ def mk_artwork(artwork_attr, typ, content)
613
+ "<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
614
+ end
615
+
598
616
  def convert_blockquote(el, indent, opts)
599
617
  text = inner(el, indent, opts)
600
618
  if $options.v3
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.5.13
4
+ version: 1.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann