kramdown-rfc2629 1.5.10 → 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: 3f3134dbcc71753f5f8d41c106172e353dbcadf2f602dc378422e23d16c1e845
4
- data.tar.gz: b0041cbd654edb611666733ada47a616e350e7f23ba32e9934df208d05fa5ff7
3
+ metadata.gz: 3097408dcedb58eab67f2de242d7ba51f8e62e82199e9da00b6a68ca0917c3dc
4
+ data.tar.gz: fbcac44963fb8a7ce2df22060e624410e8f7df4c439d2e7cdcc1fcb760f3b1c4
5
5
  SHA512:
6
- metadata.gz: 795dfb70c7a96163cdd6ea5de3cca2503a68a2294909c0c6183a953b1b670ff632869e790a1d2bdb73f485115881fcd5eef6cb1b6a157b5a3f93bce13b8ccc4e
7
- data.tar.gz: 64890d6e25973ede38f5bc2888f04d2129a0c247ca6ed60eb4200db5b94fdfb460e84b8389949ec5428e56b35dce6083ec2cb0d1536b0bc24d2e512b830cfaac
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.10'
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.}
@@ -51,10 +51,6 @@ module KramdownRFC
51
51
  # -- only works for people with exactly one last name and uncomplicated first names
52
52
  if n = aups.rest["name"]
53
53
  n = n.split
54
- if s = aups.rest["surname"]
55
- s = s.split
56
- # XXX remove s from n; use n[0..-2] otherwise.
57
- end
58
54
  aups.rest["initials"] ||= n[0..-2].map(&:chr).join('.') << '.'
59
55
  aups.rest["surname"] ||= n[-1]
60
56
  end
@@ -447,55 +447,84 @@ 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
466
+ when "protocol", "protocol-goat", "protocol-aasvg"
467
+ cmdparm = result.lines.map(&:strip).select {|x| x != ''}.join(',')
468
+ result, err, _s = Open3.capture3("protocol #{Shellwords.escape(cmdparm)}#{txt_opt}", stdin_data: '')
469
+ if t == "protocol-goat"
470
+ file.unlink
471
+ file = Tempfile.new("kramdown-rfc")
472
+ file.write(result)
473
+ file.close
474
+ result1, err, _s = Open3.capture3("goat#{svg_opt} #{file.path}", stdin_data: result);
475
+ dont_clean = true
476
+ elsif t == "protocol-aasvg"
477
+ result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
478
+ dont_clean = true
479
+ else
480
+ result1 = nil
481
+ end
458
482
  when "goat"
459
- 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);
484
+ dont_clean = true
485
+ when "aasvg"
486
+ result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
460
487
  dont_clean = true
461
488
  when "ditaa" # XXX: This needs some form of option-setting
462
- 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);
463
490
  when "mscgen"
464
- 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);
465
492
  when "mermaid"
466
- 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
467
494
  outpath = file.path + ".svg"
468
495
  result1 = File.read(outpath) rescue '' # don't die before providing error message
469
496
  File.unlink(outpath) rescue nil # ditto
470
497
  when "plantuml", "plantuml-utxt"
471
498
  plantuml = "@startuml\n#{result}\n@enduml"
472
- result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
473
- 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"
474
501
  err << err1.to_s
475
502
  when "railroad", "railroad-utf8"
476
- 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);
477
504
  result1 = svg_clean_kgt(result1); dont_clean = true
478
- 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}",
479
506
  stdin_data: result);
480
507
  err << err1.to_s
481
508
  when "math"
482
- result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
483
- 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}")
484
511
  err << err1
485
512
  end
486
513
  capture_croak(t, err)
487
514
  # warn ["text:", result.inspect]
488
515
  # warn ["svg:", result1.inspect]
489
516
  file.unlink
490
- result1 = svg_clean(result1) unless dont_clean
491
- unless dont_check
492
- result1, err, _s = Open3.capture3("svgcheck -Xqa", stdin_data: result1);
493
- # warn ["svgcheck:", result1.inspect]
494
- capture_croak("svgcheck", err)
495
- end
496
- if result1 == ''
497
- warn "*** could not create svg for #{result.inspect[0...20]}..."
498
- exit 65 # EX_DATAERR
517
+ if result1
518
+ result1 = svg_clean(result1) unless dont_clean
519
+ unless dont_check
520
+ result1, err, _s = Open3.capture3("svgcheck -Xqa", stdin_data: result1);
521
+ # warn ["svgcheck:", result1.inspect]
522
+ capture_croak("svgcheck", err)
523
+ end
524
+ if result1 == ''
525
+ warn "*** could not create svg for #{result.inspect[0...20]}..."
526
+ exit 65 # EX_DATAERR
527
+ end
499
528
  end
500
529
  [result, result1] # text, svg
501
530
  end
@@ -547,13 +576,26 @@ COLORS
547
576
  end
548
577
  end
549
578
  case t
550
- when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",
551
- "railroad", "railroad-utf8", "mermaid", "math"
579
+ when "aasvg", "ditaa", "goat",
580
+ "math", "mermaid", "mscgen",
581
+ "plantuml", "plantuml-utxt",
582
+ "protocol", "protocol-aasvg", "protocol-goat",
583
+ "railroad", "railroad-utf8"
552
584
  if gi
553
585
  warn "*** Can't set GI #{gi} for composite SVG artset"
554
586
  end
555
- result, result1 = memoize(:svg_tool_process, t, result)
556
- "#{' '*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"
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>"
597
+ end
598
+ "#{' '*indent}<figure#{el_html_attributes(el)}>#{retart}</figure>\n"
557
599
  else
558
600
  gi ||= (
559
601
  if !$options.v3 || !t || ARTWORK_TYPES.include?(t) || artwork_attr["align"]
@@ -567,6 +609,10 @@ COLORS
567
609
  end
568
610
  end
569
611
 
612
+ def mk_artwork(artwork_attr, typ, content)
613
+ "<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
614
+ end
615
+
570
616
  def convert_blockquote(el, indent, opts)
571
617
  text = inner(el, indent, opts)
572
618
  if $options.v3
@@ -618,7 +664,7 @@ COLORS
618
664
  if sl = el.attr.delete('slugifiedName') # could do general name- play
619
665
  attrstring = html_attributes({'slugifiedName' => sl})
620
666
  end
621
- irefs = "<name#{attrstring}>#{inner(el, indent, opts)}</name>" #
667
+ irefs = "<name#{attrstring}>#{inner(el, indent, opts.merge(noabbrev: true))}</name>" #
622
668
  else
623
669
  clean, irefs = clean_pcdata(inner_a(el, indent, opts))
624
670
  el.attr['title'] = clean
@@ -1205,13 +1251,30 @@ COLORS
1205
1251
  end
1206
1252
 
1207
1253
  def convert_abbreviation(el, indent, opts) # XXX: This is wrong
1254
+ if opts[:noabbrev]
1255
+ return el.value
1256
+ end
1257
+
1208
1258
  title = @root.options[:abbrev_defs][el.value]
1209
1259
  title = nil if title.empty?
1210
1260
  value = el.value
1211
- if item = title
1212
- if item == "<bcp14>" && $options.v3
1213
- return "<bcp14>#{el.value}</bcp14>"
1261
+
1262
+ if title == "<bcp14>" && $options.v3
1263
+ return "<bcp14>#{value}</bcp14>"
1264
+ end
1265
+
1266
+ if title && title[0] == "#"
1267
+ target, title = title.split(' ', 2)
1268
+ if target == "#"
1269
+ target = value
1270
+ else
1271
+ target = target[1..]
1214
1272
  end
1273
+ else
1274
+ target = nil
1275
+ end
1276
+
1277
+ if item = title
1215
1278
  m = title.scan(Parser::RFC2629Kramdown::IREF_START)
1216
1279
  if m.empty?
1217
1280
  subitem = value
@@ -1222,7 +1285,11 @@ COLORS
1222
1285
  item = value
1223
1286
  end
1224
1287
  iref ||= "<iref#{html_attributes(item: item, subitem: subitem)}/>"
1225
- "#{el.value}#{iref}"
1288
+ if target
1289
+ "<xref#{html_attributes(target: target, format: "none")}>#{value}</xref>#{iref}"
1290
+ else
1291
+ "#{value}#{iref}"
1292
+ end
1226
1293
  end
1227
1294
 
1228
1295
  def convert_root(el, indent, opts)
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.5.10
4
+ version: 1.5.14
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-10-15 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown