kramdown-rfc2629 1.5.1 → 1.5.5

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: 296e6b41d770f71cc7266daefdbef48425bd7b050ae3be467badabf1f2f8453d
4
- data.tar.gz: 12ca2cd06a9d6911f4f4db728210909ccb23a44563c4ae8ac5beaaf044fb550e
3
+ metadata.gz: 241fa7d714b5ba3a4bc0060d59d9ae2e2241b4777a60023126570e6f48bdf26f
4
+ data.tar.gz: b51688aab8adba3ad3b351ecb7d15f52ab71acf70d0c4d27ab72f8ec4d377995
5
5
  SHA512:
6
- metadata.gz: b8adf6c1c27f37b30468b6c593f3faa334adfba8953f99160ac842bfcc98bb7dde0ef02e36ea65450b9ea519ac46a200e5631c9a3bd5832296ef78b7aa18fb8a
7
- data.tar.gz: ee84d6769775ea513fea5240bdf1d552f7a724213840363d76a0510a53d9cae8ae56dd2de342f6b1540f5e2c5f9fe085b53ad7e4ca9ccd15ee598798f7a2be65
6
+ metadata.gz: fdde5cb2f7a8288476259eaa03216c12f1ed231c10275bd3a5b7679d64cbb23b65e00afa3e06dc497a028ffc0997c039f3e909c6ad661d0244208f3fa08c1f03
7
+ data.tar.gz: 16e3c5e17dd0d7b383c0cd875ea55572ccf8b6c6c1875436873cbbd93d9ab64171e9b93561b5a7f1d8c5ceb301adde38132a2ff10e8e70f66f783a7aade16d37
data/bin/kramdown-rfc2629 CHANGED
@@ -12,6 +12,24 @@ KDRFC_VERSION=Gem.loaded_specs["kramdown-rfc2629"].version rescue "unknown-versi
12
12
 
13
13
  Encoding.default_external = "UTF-8" # wake up, smell the coffee
14
14
 
15
+ # Note that this doesn't attempt to handle HT characters
16
+ def remove_indentation(s)
17
+ l = s.lines
18
+ indent = l.grep(/\S/).map {|l| l[/^\s*/].size}.min
19
+ l.map {|li| li.sub(/^ {0,#{indent}}/, "")}.join
20
+ end
21
+
22
+ def add_quote(s)
23
+ l = s.lines
24
+ l.map {|li| "> #{li}"}.join
25
+ end
26
+
27
+ def process_chunk(s, dedent, quote)
28
+ s = remove_indentation(s) if dedent
29
+ s = add_quote(s) if quote
30
+ s
31
+ end
32
+
15
33
  def boilerplate(key)
16
34
  case key.downcase
17
35
  when /\Abcp14(info)?(\+)?(-tagged)?\z/i
@@ -437,8 +455,34 @@ if input[-1] != "\n"
437
455
  # warn "*** added missing newline at end"
438
456
  input << "\n" # fix #26
439
457
  end
440
- input.gsub!(/^\{::include\s+(.*?)\}/) {
441
- File.read($1).chomp
458
+ input.gsub!(/^\{::include((?:-[a-z]+)*)\s+(.*?)\}/) {
459
+ include_flags = $1
460
+ fn = [$2]
461
+ chunks = false
462
+ dedent = false
463
+ quote = false
464
+ include_flags.split("-") do |flag|
465
+ case flag
466
+ when ""
467
+ when "quote"
468
+ quote = true
469
+ when "dedent"
470
+ dedent = true
471
+ when "all", "last"
472
+ fn = fn.flat_map{|n| Dir[n]}
473
+ fn = [fn.last] if flag == "last"
474
+ chunks = fn.map{ |f|
475
+ ret = process_chunk(File.read(f), dedent, quote)
476
+ dedent = false; quote = false
477
+ ret
478
+ }
479
+ else
480
+ warn "** unknown include flag #{flag}"
481
+ end
482
+ end
483
+ chunks = fn.map{|f| File.read(f)} unless chunks # no all/last
484
+ chunks = chunks.map {|ch| process_chunk(ch, dedent, quote)}
485
+ chunks.join.chomp
442
486
  } unless ENV["KRAMDOWN_SAFE"]
443
487
  input.gsub!(/^\{::boilerplate\s+(.*?)\}/) {
444
488
  boilerplate($1)
@@ -69,6 +69,17 @@
69
69
 
70
70
  <middle>
71
71
 
72
+ {:/nomarkdown}
73
+ {:quote: gi="blockquote"}
74
+ {:aside: gi="aside"}
75
+ {:markers: sourcecode-markers="true"}
76
+ {:unnumbered: numbered="false"}
77
+ {:vspace: vspace="0"}
78
+ {:removeinrfc: removeinrfc="true"}
79
+ {:notoc: toc="exclude"}
80
+ {:compact: spacing="compact"}
81
+ {::nomarkdown}
82
+
72
83
  <%= sechash.delete("middle") %>
73
84
 
74
85
  </middle>
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.5.1'
3
+ s.version = '1.5.5'
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.}
@@ -57,17 +57,35 @@ module KramdownRFC
57
57
  aups
58
58
  end
59
59
 
60
+ # The below anticipates the "postalLine" changes.
61
+ # If a postalLine is used (abbreviated "postal" in YAML),
62
+ # non-postalLine elements are appended as further postalLines.
63
+ # This prepares for how "country" is expected to be handled
64
+ # specially with the next schema update.
65
+ # So an address is now best keyboarded as:
66
+ # postal:
67
+ # - Foo Street
68
+ # - 28359 Bar
69
+ # country: Germany
70
+
60
71
  PERSON_ERB = <<~ERB
61
72
  <<%= element_name%> <%=aups.attrs("initials", "surname", "fullname=name", "role")%>>
62
73
  <%= aups.ele("organization=org", aups.attrs("abbrev=orgabbrev",
63
74
  *[$options.v3 && "ascii=orgascii"]), "") %>
64
75
  <address>
65
- <% postal = %w{street city region code country}.select{|gi| aups.has(gi)}
66
- if postal != [] -%>
76
+ <% postal_elements = %w{extaddr pobox street cityarea city region code sortingcode country postal}.select{|gi| aups.has(gi)}
77
+ if postal_elements != [] -%>
67
78
  <postal>
68
- <% postal.each do |gi| -%>
79
+ <% if pl = postal_elements.delete("postal") -%>
80
+ <%= aups.ele("postalLine=postal") %>
81
+ <% postal_elements.each do |gi| -%>
82
+ <%= aups.ele("postalLine=" << gi) %>
83
+ <% end -%>
84
+ <% else -%>
85
+ <% postal_elements.each do |gi| -%>
69
86
  <%= aups.ele(gi) %>
70
87
  <% end -%>
88
+ <% end -%>
71
89
  </postal>
72
90
  <% end -%>
73
91
  <% %w{phone facsimile email uri}.select{|gi| aups.has(gi)}.each do |gi| -%>
@@ -128,9 +128,14 @@ module Kramdown
128
128
  when /\A(.*) \((#{SECTIONS_RE})\)\z/
129
129
  href = $1
130
130
  handle_bares($2, attr, "parens", href)
131
- when /\A(#{XREF_BASE})<(.+)\z/
132
- href = $2
133
- attr['section'] = $1
131
+ when /#{XREF_RE_M}<(.+)\z/
132
+ href = $3
133
+ if $2
134
+ attr['section'] = $2
135
+ attr['relative'] = "#" << $1
136
+ else
137
+ attr['section'] = $1
138
+ end
134
139
  attr['sectionFormat'] = 'bare'
135
140
  when /\A<<(.+)\z/
136
141
  href = $1
@@ -374,8 +379,20 @@ COLORS
374
379
  end
375
380
  end
376
381
 
382
+ SVG_NAMESPACES = {"xmlns"=>"http://www.w3.org/2000/svg",
383
+ "xlink"=>"http://www.w3.org/1999/xlink"}
384
+
377
385
  def svg_clean_kgt(s)
378
386
  d = REXML::Document.new(s)
387
+ REXML::XPath.each(d.root, "/xmlns:svg", SVG_NAMESPACES) do |x|
388
+ if (w = x.attributes["width"]) && (h = x.attributes["height"])
389
+ x.attributes["viewBox"] = "0 0 %d %d" % [w, h]
390
+ end
391
+ if x.attributes["viewBox"]
392
+ x.attributes["width"] = nil
393
+ x.attributes["height"] = nil
394
+ end
395
+ end
379
396
  REXML::XPath.each(d.root, "//rect|//line|//path") do |x|
380
397
  x.attributes["fill"] = "none"
381
398
  x.attributes["stroke"] = "black"
@@ -548,8 +565,17 @@ COLORS
548
565
 
549
566
  def convert_blockquote(el, indent, opts)
550
567
  text = inner(el, indent, opts)
568
+ if $options.v3
569
+ gi = el.attr.delete('gi')
570
+ if gi && gi != 'ul'
571
+ "#{' '*indent}<#{gi}#{el_html_attributes(el)}>\n#{text}#{' '*indent}</#{gi}>\n"
572
+ else
573
+ "#{' '*indent}<ul#{el_html_attributes_with(el, {"empty" => 'true'})}><li>\n#{text}#{' '*indent}</li></ul>\n"
574
+ end
575
+ else
551
576
  text = "<t></t>" unless text =~ /</ # empty block quote
552
577
  "#{' '*indent}<t><list style='empty'#{el_html_attributes(el)}>\n#{text}#{' '*indent}</list></t>\n"
578
+ end
553
579
  end
554
580
 
555
581
  def end_sections(to_level, indent)
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.1
4
+ version: 1.5.5
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-07-13 00:00:00.000000000 Z
11
+ date: 2021-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown