kramdown-rfc2629 1.5.14 → 1.5.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/kramdown-rfc2629.erb +48 -0
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/parameterset.rb +3 -0
- data/lib/kramdown-rfc2629.rb +62 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1899e3dda0205ba1affda979ec1e972a27fc7d13ae721737e14cf4ab737b13ff
|
4
|
+
data.tar.gz: 442106a989c71107a357d7c0bfec6ed9cf6b51c23cbfe870c81a26adc4542438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1072b3d275c6ff6692bdc2cb3e666ac76f3c4838d6978b822c034b6ac4c70bf29a5d0be20aad42881bd9dcdf1ef5b69decb59114ecbfbb4457988ef0b0a2f3aa
|
7
|
+
data.tar.gz: 81360978cd5ff6692263c0b0b3aff2780b0b806ed83edd2d96ac40e5f705120ed54a529b874a51b27d25be10b44f14fd4bb84a7d7fe067dd3b2b73e4e1234714
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -42,6 +42,53 @@
|
|
42
42
|
|
43
43
|
</abstract>
|
44
44
|
|
45
|
+
<% if $options.v3 -%>
|
46
|
+
<% venue = ps[:venue] -%>
|
47
|
+
<% if venue -%>
|
48
|
+
<% venue = KramdownRFC::ParameterSet.new(venue) -%>
|
49
|
+
<note title="About This Document" removeInRFC="true">
|
50
|
+
<% if (dn = ps.av[:docName]) &&
|
51
|
+
(dt = dn.rpartition('-')[0]) != ""
|
52
|
+
-%>
|
53
|
+
<t>
|
54
|
+
<% if latest = venue[:latest] -%>
|
55
|
+
The latest revision of this draft can be found at <eref target="<%=latest%>"/>.
|
56
|
+
<% end -%>
|
57
|
+
Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/<%=dt%>/"/>.
|
58
|
+
</t>
|
59
|
+
<% end -%>
|
60
|
+
<% mail = venue[:mail] -%>
|
61
|
+
<% homepage = venue[:home] -%>
|
62
|
+
<% gtype = venue[:type] -%>
|
63
|
+
<% if mail || homepage -%>
|
64
|
+
<t>
|
65
|
+
<% end -%>
|
66
|
+
<% if mail && (mail_local, mail_host = mail.split("@", 2)) && mail_host -%>
|
67
|
+
<% mail_subdomain, mail_domain = mail_host.split(".", 2) -%>
|
68
|
+
<% group = venue[:group] || mail_local # XXX -%>
|
69
|
+
<% arch = venue[:arch] || "https://mailarchive.ietf.org/arch/browse/#{mail_local}/" -%>
|
70
|
+
<% GROUPS = {"ietf" => "Working ", "irtf" => "Research "} -%>
|
71
|
+
<% gtype ||= "#{GROUPS[mail_subdomain]}Group" -%>
|
72
|
+
Discussion of this document takes place on the
|
73
|
+
<%=group%> <%=gtype%> mailing list (<eref target="mailto:<%=mail%>"/>),
|
74
|
+
which is archived at <eref target="<%=arch%>"/>.
|
75
|
+
<% end -%>
|
76
|
+
<% if homepage -%>
|
77
|
+
<%=gtype%> information can be found at <eref target="<%=homepage%>"/>.
|
78
|
+
<% end -%>
|
79
|
+
<% if mail || homepage -%>
|
80
|
+
</t>
|
81
|
+
<% end -%>
|
82
|
+
<% if repo = venue[:repo] || ((gh = venue[:github]) && "https://github.com/#{gh}") -%>
|
83
|
+
<t>Source for this draft and an issue tracker can be found at
|
84
|
+
<eref target="<%=repo%>"/>.</t>
|
85
|
+
<% end -%>
|
86
|
+
<%= venue.ele("t=text", nil, nil, true) -%>
|
87
|
+
</note>
|
88
|
+
<% venue.warn_if_leftovers -%>
|
89
|
+
<% end -%>
|
90
|
+
<% end -%>
|
91
|
+
|
45
92
|
<% sechash.keys.each do |k| -%>
|
46
93
|
<% if k =~ /\A(to_be_removed_)?note_(.*)/ -%>
|
47
94
|
|
@@ -78,6 +125,7 @@
|
|
78
125
|
{:removeinrfc: removeinrfc="true"}
|
79
126
|
{:notoc: toc="exclude"}
|
80
127
|
{:compact: spacing="compact"}
|
128
|
+
{:noabbrev: noabbrev="true"}
|
81
129
|
{::nomarkdown}
|
82
130
|
|
83
131
|
<%= sechash.delete("middle") %>
|
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.5.
|
3
|
+
s.version = '1.5.18'
|
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.}
|
@@ -7,7 +7,9 @@ module KramdownRFC
|
|
7
7
|
def initialize(y)
|
8
8
|
raise "*** invalid parameter set #{y.inspect}" unless Hash === y
|
9
9
|
@f = y
|
10
|
+
@av = {}
|
10
11
|
end
|
12
|
+
attr :av
|
11
13
|
def [](pn)
|
12
14
|
@f.delete(pn.to_s)
|
13
15
|
end
|
@@ -24,6 +26,7 @@ module KramdownRFC
|
|
24
26
|
end
|
25
27
|
def attr(pn)
|
26
28
|
val, an = van(pn)
|
29
|
+
@av[an.intern] = val
|
27
30
|
%{#{an}="#{escattr(val)}"} if val
|
28
31
|
end
|
29
32
|
def attrs(*pns)
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -34,6 +34,18 @@ module Kramdown
|
|
34
34
|
|
35
35
|
class RFC2629Kramdown < Kramdown
|
36
36
|
|
37
|
+
def replace_abbreviations(el, regexps = nil)
|
38
|
+
unless regexps # DUPLICATED AND MODIFIED CODE FROM UPSTREAM, CHECK ON UPSTREAM UPGRADE
|
39
|
+
sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length }
|
40
|
+
regexps = [Regexp.union(*sorted_abbrevs.map {|k|
|
41
|
+
/#{Regexp.escape(k).gsub(/\\\s/, "[\\s\\p{Z}]+").force_encoding(Encoding::UTF_8)}/})]
|
42
|
+
# warn regexps.inspect
|
43
|
+
regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
|
44
|
+
end
|
45
|
+
super(el, regexps)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
37
49
|
def initialize(*doc)
|
38
50
|
super
|
39
51
|
@span_parsers.unshift(:xref)
|
@@ -226,7 +238,11 @@ module Kramdown
|
|
226
238
|
)
|
227
239
|
STUDLY_ATTR_MAP = Hash[STUDLY_ATTR.map {|s| [s.downcase, s]}]
|
228
240
|
|
229
|
-
|
241
|
+
TRUTHY = Hash.new {|h, k| k}
|
242
|
+
TRUTHY["false"] = false
|
243
|
+
TRUTHY["no"] = false
|
244
|
+
|
245
|
+
def rfc2629_fix(opts)
|
230
246
|
if a = attr
|
231
247
|
if anchor = a.delete('id')
|
232
248
|
a['anchor'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
|
@@ -234,12 +250,16 @@ module Kramdown
|
|
234
250
|
if anchor = a.delete('href')
|
235
251
|
a['target'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
|
236
252
|
end
|
253
|
+
if av = a.delete('noabbrev') # pseudo attribute -> opts
|
254
|
+
opts = opts.merge(noabbrev: TRUTHY[av]) # updated copy
|
255
|
+
end
|
237
256
|
attr.keys.each do |k|
|
238
257
|
if (d = k.gsub(/_(.|$)/) { $1.upcase }) != k or d = STUDLY_ATTR_MAP[k]
|
239
258
|
a[d] = a.delete(k)
|
240
259
|
end
|
241
260
|
end
|
242
261
|
end
|
262
|
+
opts
|
243
263
|
end
|
244
264
|
end
|
245
265
|
|
@@ -294,15 +314,15 @@ module Kramdown
|
|
294
314
|
end
|
295
315
|
|
296
316
|
def convert1(el, indent, opts = {})
|
297
|
-
el.rfc2629_fix
|
298
|
-
send("convert_#{el.type}", el, indent,
|
317
|
+
nopts = el.rfc2629_fix(opts)
|
318
|
+
send("convert_#{el.type}", el, indent, nopts)
|
299
319
|
end
|
300
320
|
|
301
321
|
def inner_a(el, indent, opts)
|
302
322
|
indent += INDENTATION
|
303
323
|
el.children.map do |inner_el|
|
304
|
-
inner_el.rfc2629_fix
|
305
|
-
send("convert_#{inner_el.type}", inner_el, indent,
|
324
|
+
nopts = inner_el.rfc2629_fix(opts)
|
325
|
+
send("convert_#{inner_el.type}", inner_el, indent, nopts)
|
306
326
|
end
|
307
327
|
end
|
308
328
|
|
@@ -604,6 +624,35 @@ COLORS
|
|
604
624
|
"sourcecode"
|
605
625
|
end
|
606
626
|
)
|
627
|
+
loc_str =
|
628
|
+
if anchor = el.attr['anchor']
|
629
|
+
"##{anchor}"
|
630
|
+
elsif lineno = el.options[:location]
|
631
|
+
"approx. line #{lineno}" # XXX
|
632
|
+
else
|
633
|
+
"UNKNOWN"
|
634
|
+
end
|
635
|
+
case t
|
636
|
+
when "json"
|
637
|
+
begin
|
638
|
+
JSON.load(result)
|
639
|
+
rescue => e
|
640
|
+
err1 = "*** #{loc_str}: JSON isn't: #{e.message[0..40]}\n"
|
641
|
+
begin
|
642
|
+
JSON.load("{" << result << "}")
|
643
|
+
rescue => e
|
644
|
+
warn err1 << "*** not even with braces added around: #{e.message[0..40]}"
|
645
|
+
end
|
646
|
+
end
|
647
|
+
when "json-from-yaml"
|
648
|
+
begin
|
649
|
+
y = YAML.safe_load(result, aliases: true, filename: loc_str)
|
650
|
+
result = JSON.pretty_generate(y)
|
651
|
+
t = "json" # XXX, this could be another format!
|
652
|
+
rescue => e
|
653
|
+
warn "*** YAML isn't: #{e.message}\n"
|
654
|
+
end
|
655
|
+
end
|
607
656
|
"#{' '*indent}<figure#{el_html_attributes(el)}><#{gi}#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></#{gi}></figure>\n"
|
608
657
|
end
|
609
658
|
end
|
@@ -664,6 +713,7 @@ COLORS
|
|
664
713
|
if sl = el.attr.delete('slugifiedName') # could do general name- play
|
665
714
|
attrstring = html_attributes({'slugifiedName' => sl})
|
666
715
|
end
|
716
|
+
# noabbrev: true -- Workaround for https://trac.ietf.org/trac/xml2rfc/ticket/683
|
667
717
|
irefs = "<name#{attrstring}>#{inner(el, indent, opts.merge(noabbrev: true))}</name>" #
|
668
718
|
else
|
669
719
|
clean, irefs = clean_pcdata(inner_a(el, indent, opts))
|
@@ -1255,9 +1305,14 @@ COLORS
|
|
1255
1305
|
return el.value
|
1256
1306
|
end
|
1257
1307
|
|
1258
|
-
title = @root.options[:abbrev_defs][el.value]
|
1259
|
-
title = nil if title.empty?
|
1260
1308
|
value = el.value
|
1309
|
+
ix = value.gsub(/[\s\p{Z}]+/, " ")
|
1310
|
+
title = @root.options[:abbrev_defs][ix]
|
1311
|
+
if title.nil?
|
1312
|
+
warn "*** abbrev mismatch: value = #{value.inspect} ix = #{ix.inspect}"
|
1313
|
+
else
|
1314
|
+
title = nil if title.empty?
|
1315
|
+
end
|
1261
1316
|
|
1262
1317
|
if title == "<bcp14>" && $options.v3
|
1263
1318
|
return "<bcp14>#{value}</bcp14>"
|
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.
|
4
|
+
version: 1.5.18
|
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-
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|