kramdown-rfc2629 1.3.18 → 1.3.24

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: 28fbdd54743e2c20350291a2d61dae4fe326e23e55931316547fbdbd9648f8b7
4
- data.tar.gz: c6d612a256598e8bfcf65e17cdf1da082c673e3d090d9a735bcfc7059580d4e0
3
+ metadata.gz: 4917395db5dce706708b9a3ce81da25a4089d0982b6f6c577fe2249248718f3c
4
+ data.tar.gz: c2c3a7ce6d9269674a20dcbd793e2bd0f451cee98fa36dbe5b2be47b29d76f30
5
5
  SHA512:
6
- metadata.gz: 6383c69fff2b3f1b8aa67c14ce114053a53cbce20ff0af9bbfcc114ed196073609f2c90cfd94f79807f9f45ebb17d0c68e4785b912b6cd6de23bfccac8fb7dac
7
- data.tar.gz: a2d196a6e43d53e363689161bb5a57b694754fc23792352db4d9c5c085d7d6cda15aa96491b8775a459d20e31d61c6b52ffb5f276d238e6e51e4a2d2976e7bdd
6
+ metadata.gz: 3818e58468fef81b14fb7bf7e399a0ba740ed08a3b2e2b98a0e4e2019c536a456aec5678e1e3a6a525800d236a245bd86f05bf07610048c287f72c633cb1355d
7
+ data.tar.gz: 884d1d3650106e695294dfdf96a534db6e1f40fd7204e10bfab118fc50ebca1db65b28762d52c57884732f65da37183c83a34834cbad21a6c9a1f77db6f7e023
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.18'
3
+ s.version = '1.3.24'
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.}
@@ -39,7 +39,36 @@ module Kramdown
39
39
  @span_parsers.unshift(:iref)
40
40
  end
41
41
 
42
- XREF_START = /\{\{(?:(?:\{(.*?)\}(?:\{(.*?)\})?)|(.*?))((?:\}\})|\})/u
42
+ SECTIONS_RE = /Section(?:s (?:[\w.]+, )*[\w.]+,? and)? [\w.]+/
43
+
44
+ def handle_bares(s, attr, format, href)
45
+ sa = s.sub(/\A\S+\s/, '').split(/,? and /)
46
+ sa[0..0] = *sa[0].split(', ')
47
+ sz = sa.size
48
+ if sz != 1 # we have to redo xml2rfc's work here
49
+ @tree.children << Element.new(:text, "Sections ", {}) # XXX needs to split into Section/Appendix
50
+ sa.each_with_index do |sec, i|
51
+ attr1 = {"target" => href, "section" => sec, "sectionFormat" => "bare"}
52
+ @tree.children << Element.new(:xref, nil, attr1)
53
+ text = if i == 0 && sz == 2
54
+ " and "
55
+ elsif i == sz-1
56
+ " of "
57
+ elsif i == sz-2
58
+ ", and "
59
+ else
60
+ ", "
61
+ end
62
+ @tree.children << Element.new(:text, text, {})
63
+ end
64
+ # attr stays unchanged, no section added
65
+ else
66
+ attr['section'] = sa[-1]
67
+ attr['sectionFormat'] = format
68
+ end
69
+ end
70
+
71
+ XREF_START = /\{\{(?:(?:\{(.*?)\}(?:\{(.*?)\})?)|(\X*?))((?:\}\})|\})/u
43
72
 
44
73
  # Introduce new {{target}} syntax for empty xrefs, which would
45
74
  # otherwise be an ugly ![!](target) or ![ ](target)
@@ -57,8 +86,28 @@ module Kramdown
57
86
  el = Element.new(:contact, nil, attr)
58
87
  else
59
88
  href = @src[3]
89
+ attr = {}
90
+ if $options.v3
91
+ # match Section ... of ...; set section, sectionFormat
92
+ case href.gsub(/[\u00A0\s]+/, ' ') # may need nbsp and/or newlines
93
+ when /\A(#{SECTIONS_RE}) of (.*)\z/
94
+ href = $2
95
+ handle_bares($1, attr, "of", href)
96
+ when /\A(.*), (#{SECTIONS_RE})\z/
97
+ href = $1
98
+ handle_bares($2, attr, "comma", href)
99
+ when /\A(.*) \((#{SECTIONS_RE})\)\z/
100
+ href = $1
101
+ handle_bares($2, attr, "parens", href)
102
+ when /\A([\w.]+)<(.*)\z/
103
+ href = $2
104
+ attr['section'] = $1
105
+ attr['sectionFormat'] = 'bare'
106
+ end
107
+ end
60
108
  href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
61
- el = Element.new(:xref, nil, {'target' => href})
109
+ attr['target'] = href
110
+ el = Element.new(:xref, nil, attr)
62
111
  end
63
112
  @tree.children << el
64
113
  end
@@ -79,6 +128,22 @@ module Kramdown
79
128
  end
80
129
 
81
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
+
82
147
  def rfc2629_fix
83
148
  if a = attr
84
149
  if anchor = a.delete('id')
@@ -87,6 +152,11 @@ module Kramdown
87
152
  if anchor = a.delete('href')
88
153
  a['target'] = anchor
89
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
90
160
  end
91
161
  end
92
162
  end
@@ -373,8 +443,15 @@ COLORS
373
443
  if options[:auto_ids] && !el.attr['anchor']
374
444
  el.attr['anchor'] = saner_generate_id(el.options[:raw_text])
375
445
  end
446
+ if $options.v3
447
+ if sl = el.attr.delete('slugifiedName') # could do general name- play
448
+ attrstring = html_attributes({'slugifiedName' => sl})
449
+ end
450
+ irefs = "<name#{attrstring}>#{inner(el, indent, opts)}</name>" #
451
+ else
376
452
  clean, irefs = clean_pcdata(inner_a(el, indent, opts))
377
453
  el.attr['title'] = clean
454
+ end
378
455
  "#{end_sections(el.options[:level], indent)}#{' '*indent}<section#{@sec_level += 1; el_html_attributes(el)}>#{irefs}\n"
379
456
  end
380
457
 
@@ -397,6 +474,9 @@ COLORS
397
474
 
398
475
  def convert_dl(el, indent, opts)
399
476
  if $options.v3
477
+ if hangindent = el.attr.delete('hangIndent')
478
+ el.attr['indent'] ||= hangindent # new attribute name wins
479
+ end
400
480
  vspace = el.attr.delete('vspace')
401
481
  if vspace && !el.attr['newline']
402
482
  el.attr['newline'] = 'true'
@@ -752,9 +832,14 @@ COLORS
752
832
  EMPH = { em: "emph", strong: "strong"}
753
833
 
754
834
  def convert_em(el, indent, opts)
835
+ if $options.v3
836
+ gi = el.type
837
+ "<#{gi}#{el_html_attributes(el)}>#{inner(el, indent, opts)}</#{gi}>"
838
+ else
755
839
  attrstring = el_html_attributes_with(el, {"style" => EMPH[el.type]})
756
840
  span, irefs = clean_pcdata(inner_a(el, indent, opts))
757
841
  "<spanx#{attrstring}>#{span}</spanx>#{irefs}"
842
+ end
758
843
  end
759
844
  alias :convert_strong :convert_em
760
845
 
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.18
4
+ version: 1.3.24
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-09 00:00:00.000000000 Z
11
+ date: 2021-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.1.2
100
+ rubygems_version: 3.2.3
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Kramdown extension for generating RFC 7749 XML.