kramdown-rfc2629 1.3.20 → 1.3.25
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 +4 -4
- data/bin/kramdown-rfc2629 +3 -3
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/erb.rb +16 -0
- data/lib/kramdown-rfc/refxml.rb +4 -2
- data/lib/kramdown-rfc2629.rb +75 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a18c9460f832be1f0bb626cc1b6ea385a6535b7af585212ec0c961ae1945d36
|
4
|
+
data.tar.gz: f34512123c073979fff13351c1fdd3ec640376a604e9aba7e849652d59172023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69f0328719872f0bef0d81bffb5fa495e384f599a0fb3843cc4c9d6065811be71f21e7ab9700cb1d1f3419d5a91dc88af62c855b5f97f499519b15b11f888bef
|
7
|
+
data.tar.gz: 56778f5ec4e581ac21d17637c1098924ccd6a0b97facd12a2e636fdae755798c6ce7a545e5b8395ec17168e9e118230c1cca00e23ab8332eedbca6a0cf57dccc
|
data/bin/kramdown-rfc2629
CHANGED
@@ -4,7 +4,7 @@ require 'kramdown-rfc2629'
|
|
4
4
|
require 'kramdown-rfc/parameterset'
|
5
5
|
require 'kramdown-rfc/refxml'
|
6
6
|
require 'yaml'
|
7
|
-
require 'erb'
|
7
|
+
require 'kramdown-rfc/erb'
|
8
8
|
require 'date'
|
9
9
|
|
10
10
|
# try to get this from gemspec.
|
@@ -154,7 +154,7 @@ def xml_from_sections(input)
|
|
154
154
|
if bibref
|
155
155
|
if old = anchor_to_bibref[word]
|
156
156
|
if bibref != old
|
157
|
-
warn "*** conflicting definitions for xref #{
|
157
|
+
warn "*** conflicting definitions for xref #{word}: #{old} != #{bibref}"
|
158
158
|
end
|
159
159
|
else
|
160
160
|
anchor_to_bibref[word] = bibref
|
@@ -229,7 +229,7 @@ def xml_from_sections(input)
|
|
229
229
|
|
230
230
|
erbfilename = File.expand_path '../../data/kramdown-rfc2629.erb', __FILE__
|
231
231
|
erbfile = File.read(erbfilename, coding: "UTF-8")
|
232
|
-
erb = ERB.
|
232
|
+
erb = ERB.trim_new(erbfile, '-')
|
233
233
|
# remove redundant nomarkdown pop outs/pop ins as they confuse kramdown
|
234
234
|
input = erb.result(binding).gsub(%r"{::nomarkdown}\s*{:/nomarkdown}"m, "")
|
235
235
|
ps.warn_if_leftovers
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.3.
|
3
|
+
s.version = '1.3.25'
|
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.}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
class ERB
|
4
|
+
|
5
|
+
case version.sub("erb.rb [", "")
|
6
|
+
when /\A2.1/ # works back to 1.9.1
|
7
|
+
def self.trim_new(s, trim)
|
8
|
+
ERB.new(s, nil, trim)
|
9
|
+
end
|
10
|
+
else
|
11
|
+
def self.trim_new(s, trim)
|
12
|
+
ERB.new(s, trim_mode: trim)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/kramdown-rfc/refxml.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'kramdown-rfc/erb'
|
2
|
+
|
1
3
|
module KramdownRFC
|
2
4
|
|
3
5
|
extend Kramdown::Utils::Html
|
@@ -8,7 +10,7 @@ module KramdownRFC
|
|
8
10
|
|
9
11
|
def self.ref_to_xml(k, v)
|
10
12
|
vps = KramdownRFC::ParameterSet.new(v)
|
11
|
-
erb = ERB.
|
13
|
+
erb = ERB.trim_new <<-REFERB, '-'
|
12
14
|
<reference anchor="<%= escattr(k) %>" <%= vps.attr("target") %>>
|
13
15
|
<front>
|
14
16
|
<%= vps.ele("title") -%>
|
@@ -75,7 +77,7 @@ module KramdownRFC
|
|
75
77
|
ERB
|
76
78
|
|
77
79
|
def self.person_element_from_aups(element_name, aups)
|
78
|
-
erb = ERB.
|
80
|
+
erb = ERB.trim_new(PERSON_ERB, '-')
|
79
81
|
erb.result(binding)
|
80
82
|
end
|
81
83
|
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -39,7 +39,36 @@ module Kramdown
|
|
39
39
|
@span_parsers.unshift(:iref)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
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  or 
|
@@ -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
|
-
|
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
|
@@ -404,6 +474,9 @@ COLORS
|
|
404
474
|
|
405
475
|
def convert_dl(el, indent, opts)
|
406
476
|
if $options.v3
|
477
|
+
if hangindent = el.attr.delete('hangIndent')
|
478
|
+
el.attr['indent'] ||= hangindent # new attribute name wins
|
479
|
+
end
|
407
480
|
vspace = el.attr.delete('vspace')
|
408
481
|
if vspace && !el.attr['newline']
|
409
482
|
el.attr['newline'] = 'true'
|
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.
|
4
|
+
version: 1.3.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- data/kramdown-rfc2629.erb
|
75
75
|
- data/math.json
|
76
76
|
- kramdown-rfc2629.gemspec
|
77
|
+
- lib/kramdown-rfc/erb.rb
|
77
78
|
- lib/kramdown-rfc/gzip-clone.rb
|
78
79
|
- lib/kramdown-rfc/parameterset.rb
|
79
80
|
- lib/kramdown-rfc/refxml.rb
|
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.2.3
|
101
102
|
signing_key:
|
102
103
|
specification_version: 4
|
103
104
|
summary: Kramdown extension for generating RFC 7749 XML.
|