kramdown-rfc2629 1.5.13 → 1.5.17
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 +38 -0
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +100 -27
- 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: 437ec106fe0458259c9f776fb89ed2993ffea7a466a66f087cb2dd4a460616b3
|
4
|
+
data.tar.gz: 255a5c80a71f8e5447c59a557b58c8ccbb6bc4ad503f838650a6e5c49083b0fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a9724e14f28a37f6426b1173b25941a7fe1ed113be1a7c45da2e1bc855ae367723a5bf92c515ad6dd7da95d6616c91c8d16de51f366c0ec4c20417073c0ac8
|
7
|
+
data.tar.gz: '088030252b477385ecfa4447a4b76a472f8fbe33b0104c680feb8ea6493b4fe72334c087ec2321bfc567901595a3113750757fb35a7d69e794ef25c30071c435'
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -42,6 +42,43 @@
|
|
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="Discussion Venues" removeInRFC="true">
|
50
|
+
<% mail = venue[:mail] -%>
|
51
|
+
<% homepage = venue[:home] -%>
|
52
|
+
<% gtype = venue[:type] -%>
|
53
|
+
<% if mail || homepage -%>
|
54
|
+
<t>
|
55
|
+
<% end -%>
|
56
|
+
<% if mail -%>
|
57
|
+
<% mail_local, mail_host = mail.split("@", 2) -%>
|
58
|
+
<% mail_subdomain, mail_domain = mail_host.split(".", 2) -%>
|
59
|
+
<% group = venue[:group] || mail_local # XXX -%>
|
60
|
+
<% arch = venue[:arch] || "https://mailarchive.ietf.org/arch/browse/#{mail_local}/" -%>
|
61
|
+
<% GROUPS = {"ietf" => "Working ", "irtf" => "Research "} -%>
|
62
|
+
<% gtype ||= "#{GROUPS[mail_subdomain]}Group" -%>
|
63
|
+
Discussion of this document takes place on the
|
64
|
+
<%=group%> <%=gtype%> mailing list (<eref target="mailto:<%=mail%>"/>),
|
65
|
+
which is archived at <eref target="<%=arch%>"/>.
|
66
|
+
<% end -%>
|
67
|
+
<% if homepage -%>
|
68
|
+
<%=gtype%> information can be found at <eref target="<%=homepage%>"/>.
|
69
|
+
<% end -%>
|
70
|
+
<% if mail || homepage -%>
|
71
|
+
</t>
|
72
|
+
<% end -%>
|
73
|
+
<% if repo = venue[:repo] || ((gh = venue[:github]) && "https://github.com/#{gh}") -%>
|
74
|
+
<t>Source for this draft and an issue tracker can be found at
|
75
|
+
<eref target="<%=repo%>"/>.</t>
|
76
|
+
<% end -%>
|
77
|
+
</note>
|
78
|
+
<% venue.warn_if_leftovers -%>
|
79
|
+
<% end -%>
|
80
|
+
<% end -%>
|
81
|
+
|
45
82
|
<% sechash.keys.each do |k| -%>
|
46
83
|
<% if k =~ /\A(to_be_removed_)?note_(.*)/ -%>
|
47
84
|
|
@@ -78,6 +115,7 @@
|
|
78
115
|
{:removeinrfc: removeinrfc="true"}
|
79
116
|
{:notoc: toc="exclude"}
|
80
117
|
{:compact: spacing="compact"}
|
118
|
+
{:noabbrev: noabbrev="true"}
|
81
119
|
{::nomarkdown}
|
82
120
|
|
83
121
|
<%= 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.17'
|
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.}
|
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
|
|
@@ -447,59 +467,67 @@ COLORS
|
|
447
467
|
end
|
448
468
|
end
|
449
469
|
|
450
|
-
def
|
470
|
+
def shell_prepare(opt)
|
471
|
+
" " << opt.shellsplit.shelljoin
|
472
|
+
end
|
473
|
+
|
474
|
+
DEFAULT_AASVG="aasvg --spaces=1"
|
475
|
+
|
476
|
+
def svg_tool_process(t, svg_opt, txt_opt, result)
|
451
477
|
require 'tempfile'
|
452
478
|
file = Tempfile.new("kramdown-rfc")
|
453
479
|
file.write(result)
|
454
480
|
file.close
|
455
481
|
dont_clean = false
|
456
482
|
dont_check = false
|
483
|
+
svg_opt = shell_prepare(svg_opt) if svg_opt
|
484
|
+
txt_opt = shell_prepare(txt_opt) if txt_opt
|
457
485
|
case t
|
458
486
|
when "protocol", "protocol-goat", "protocol-aasvg"
|
459
487
|
cmdparm = result.lines.map(&:strip).select {|x| x != ''}.join(',')
|
460
|
-
result, err, _s = Open3.capture3("protocol #{Shellwords.escape(cmdparm)}", stdin_data: '')
|
488
|
+
result, err, _s = Open3.capture3("protocol #{Shellwords.escape(cmdparm)}#{txt_opt}", stdin_data: '')
|
461
489
|
if t == "protocol-goat"
|
462
490
|
file.unlink
|
463
491
|
file = Tempfile.new("kramdown-rfc")
|
464
492
|
file.write(result)
|
465
493
|
file.close
|
466
|
-
result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
|
494
|
+
result1, err, _s = Open3.capture3("goat#{svg_opt} #{file.path}", stdin_data: result);
|
467
495
|
dont_clean = true
|
468
496
|
elsif t == "protocol-aasvg"
|
469
|
-
result1, err, _s = Open3.capture3("
|
497
|
+
result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
|
470
498
|
dont_clean = true
|
471
499
|
else
|
472
500
|
result1 = nil
|
473
501
|
end
|
474
502
|
when "goat"
|
475
|
-
result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
|
503
|
+
result1, err, _s = Open3.capture3("goat#{svg_opt} #{file.path}", stdin_data: result);
|
476
504
|
dont_clean = true
|
477
505
|
when "aasvg"
|
478
|
-
result1, err, _s = Open3.capture3("
|
506
|
+
result1, err, _s = Open3.capture3("#{DEFAULT_AASVG}#{svg_opt}", stdin_data: result);
|
479
507
|
dont_clean = true
|
480
508
|
when "ditaa" # XXX: This needs some form of option-setting
|
481
|
-
result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o
|
509
|
+
result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -#{svg_opt}", stdin_data: result);
|
482
510
|
when "mscgen"
|
483
|
-
result1, err, _s = Open3.capture3("mscgen -T svg -i #{file.path} -o
|
511
|
+
result1, err, _s = Open3.capture3("mscgen -T svg -i #{file.path} -o -#{svg_opt}", stdin_data: result);
|
484
512
|
when "mermaid"
|
485
|
-
result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
|
513
|
+
result1, err, _s = Open3.capture3("mmdc -i #{file.path}#{svg_opt}", stdin_data: result); # -b transparent
|
486
514
|
outpath = file.path + ".svg"
|
487
515
|
result1 = File.read(outpath) rescue '' # don't die before providing error message
|
488
516
|
File.unlink(outpath) rescue nil # ditto
|
489
517
|
when "plantuml", "plantuml-utxt"
|
490
518
|
plantuml = "@startuml\n#{result}\n@enduml"
|
491
|
-
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
|
492
|
-
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
519
|
+
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg#{svg_opt}", stdin_data: plantuml);
|
520
|
+
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt#{txt_opt}", stdin_data: plantuml) if t == "plantuml-utxt"
|
493
521
|
err << err1.to_s
|
494
522
|
when "railroad", "railroad-utf8"
|
495
|
-
result1, err1, _s = Open3.capture3("kgt -l abnf -e svg", stdin_data: result);
|
523
|
+
result1, err1, _s = Open3.capture3("kgt -l abnf -e svg#{svg_opt}", stdin_data: result);
|
496
524
|
result1 = svg_clean_kgt(result1); dont_clean = true
|
497
|
-
result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}",
|
525
|
+
result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}#{txt_opt}",
|
498
526
|
stdin_data: result);
|
499
527
|
err << err1.to_s
|
500
528
|
when "math"
|
501
|
-
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
|
502
|
-
result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
|
529
|
+
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false#{svg_opt} #{Shellwords.escape(' ' << result)}");
|
530
|
+
result, err1, _s = Open3.capture3("asciitex -f #{file.path}#{txt_opt}")
|
503
531
|
err << err1
|
504
532
|
end
|
505
533
|
capture_croak(t, err)
|
@@ -576,12 +604,18 @@ COLORS
|
|
576
604
|
if gi
|
577
605
|
warn "*** Can't set GI #{gi} for composite SVG artset"
|
578
606
|
end
|
579
|
-
result, result1 = memoize(:svg_tool_process, t,
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
607
|
+
result, result1 = memoize(:svg_tool_process, t,
|
608
|
+
artwork_attr.delete("svg-options"),
|
609
|
+
artwork_attr.delete("txt-options"),
|
610
|
+
result)
|
611
|
+
retart = mk_artwork(artwork_attr, "ascii-art",
|
612
|
+
"<![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]>")
|
613
|
+
if result1 # nest TXT in artset with SVG
|
614
|
+
retsvg = mk_artwork(artwork_attr, "svg",
|
615
|
+
result1.sub(/.*?<svg/m, "<svg"))
|
616
|
+
retart = "<artset>#{retsvg}#{retart}</artset>"
|
584
617
|
end
|
618
|
+
"#{' '*indent}<figure#{el_html_attributes(el)}>#{retart}</figure>\n"
|
585
619
|
else
|
586
620
|
gi ||= (
|
587
621
|
if !$options.v3 || !t || ARTWORK_TYPES.include?(t) || artwork_attr["align"]
|
@@ -590,11 +624,44 @@ COLORS
|
|
590
624
|
"sourcecode"
|
591
625
|
end
|
592
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
|
593
656
|
"#{' '*indent}<figure#{el_html_attributes(el)}><#{gi}#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></#{gi}></figure>\n"
|
594
657
|
end
|
595
658
|
end
|
596
659
|
end
|
597
660
|
|
661
|
+
def mk_artwork(artwork_attr, typ, content)
|
662
|
+
"<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
|
663
|
+
end
|
664
|
+
|
598
665
|
def convert_blockquote(el, indent, opts)
|
599
666
|
text = inner(el, indent, opts)
|
600
667
|
if $options.v3
|
@@ -646,6 +713,7 @@ COLORS
|
|
646
713
|
if sl = el.attr.delete('slugifiedName') # could do general name- play
|
647
714
|
attrstring = html_attributes({'slugifiedName' => sl})
|
648
715
|
end
|
716
|
+
# noabbrev: true -- Workaround for https://trac.ietf.org/trac/xml2rfc/ticket/683
|
649
717
|
irefs = "<name#{attrstring}>#{inner(el, indent, opts.merge(noabbrev: true))}</name>" #
|
650
718
|
else
|
651
719
|
clean, irefs = clean_pcdata(inner_a(el, indent, opts))
|
@@ -1237,9 +1305,14 @@ COLORS
|
|
1237
1305
|
return el.value
|
1238
1306
|
end
|
1239
1307
|
|
1240
|
-
title = @root.options[:abbrev_defs][el.value]
|
1241
|
-
title = nil if title.empty?
|
1242
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
|
1243
1316
|
|
1244
1317
|
if title == "<bcp14>" && $options.v3
|
1245
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.17
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|