kramdown-rfc2629 1.5.19 → 1.5.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kramdown-rfc2629 +44 -30
- data/data/kramdown-rfc2629.erb +3 -2
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/parameterset.rb +1 -2
- data/lib/kramdown-rfc/rfc8792.rb +59 -0
- data/lib/kramdown-rfc2629.rb +1 -1
- 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: d7c7ac571f000360c4b8aca5450e5439c2d50b71fb85872ad2890e575c986c9b
|
4
|
+
data.tar.gz: 1af9f4b9d49c2176143a61b7c24f3bc9f13302a2bbef6a5cc90a379596b5ff04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d5ed0d4e9ec45f285a2230055a5cdbc4393a0eec6fe5722c170a965a4d24a6f5a73bf16e14e83b38fa6029a6942edacf88f5621f2e2c5c0aabd2223f73bc9f
|
7
|
+
data.tar.gz: 748fbf3adced720c4cdb48c346174d4660a17b670ee5f12fc315fd252d3353c7e8c8569bba1d4526f2c8016c85d524160e9bfac5749f3e1f40b7932c048d3a01
|
data/bin/kramdown-rfc2629
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'kramdown-rfc2629'
|
4
4
|
require 'kramdown-rfc/parameterset'
|
5
5
|
require 'kramdown-rfc/refxml'
|
6
|
+
require 'kramdown-rfc/rfc8792'
|
6
7
|
require 'yaml'
|
7
8
|
require 'kramdown-rfc/erb'
|
8
9
|
require 'date'
|
@@ -24,12 +25,53 @@ def add_quote(s)
|
|
24
25
|
l.map {|li| "> #{li}"}.join
|
25
26
|
end
|
26
27
|
|
27
|
-
def process_chunk(s, dedent, quote)
|
28
|
+
def process_chunk(s, nested, dedent, fold, quote)
|
29
|
+
process_includes(s) if nested
|
28
30
|
s = remove_indentation(s) if dedent
|
31
|
+
s = fold8792_1(s) if fold
|
29
32
|
s = add_quote(s) if quote
|
30
33
|
s
|
31
34
|
end
|
32
35
|
|
36
|
+
def process_includes(input)
|
37
|
+
input.gsub!(/^\{::include((?:-[a-z]+)*)\s+(.*?)\}/) {
|
38
|
+
include_flags = $1
|
39
|
+
fn = [$2]
|
40
|
+
chunks = false
|
41
|
+
nested = false
|
42
|
+
dedent = false
|
43
|
+
fold = false
|
44
|
+
quote = false
|
45
|
+
include_flags.split("-") do |flag|
|
46
|
+
case flag
|
47
|
+
when ""
|
48
|
+
when "nested"
|
49
|
+
nested = true
|
50
|
+
when "quote"
|
51
|
+
quote = true
|
52
|
+
when "dedent"
|
53
|
+
dedent = true
|
54
|
+
when "fold"
|
55
|
+
fold = true
|
56
|
+
when "all", "last"
|
57
|
+
fn = fn.flat_map{|n| Dir[n]}
|
58
|
+
fn = [fn.last] if flag == "last"
|
59
|
+
chunks = fn.map{ |f|
|
60
|
+
ret = process_chunk(File.read(f), nested, dedent, fold, quote)
|
61
|
+
nested = false; dedent = false; fold = false; quote = false
|
62
|
+
ret
|
63
|
+
}
|
64
|
+
else
|
65
|
+
warn "** unknown include flag #{flag}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
chunks = fn.map{|f| File.read(f)} unless chunks # no all/last
|
69
|
+
chunks = chunks.map {|ch| process_chunk(ch, nested, dedent, fold, quote)}
|
70
|
+
chunks.join.chomp
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
|
33
75
|
def boilerplate(key)
|
34
76
|
case key.downcase
|
35
77
|
when /\Abcp14(info)?(\+)?(-tagged)?\z/i
|
@@ -455,35 +497,7 @@ if input[-1] != "\n"
|
|
455
497
|
# warn "*** added missing newline at end"
|
456
498
|
input << "\n" # fix #26
|
457
499
|
end
|
458
|
-
input
|
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
|
486
|
-
} unless ENV["KRAMDOWN_SAFE"]
|
500
|
+
process_includes(input) unless ENV["KRAMDOWN_SAFE"]
|
487
501
|
input.gsub!(/^\{::boilerplate\s+(.*?)\}/) {
|
488
502
|
boilerplate($1)
|
489
503
|
}
|
data/data/kramdown-rfc2629.erb
CHANGED
@@ -22,7 +22,8 @@
|
|
22
22
|
rfcattrs = ps.attrs("ipr", "docName=docname", "category=cat",
|
23
23
|
"consensus", "submissionType=submissiontype", "xml:lang=lang",
|
24
24
|
"number", "obsoletes", "updates", "seriesNo=seriesno")
|
25
|
-
TRUE_FALSE = {nil => "true", false => "false", true => "true"
|
25
|
+
TRUE_FALSE = {nil => "true", false => "false", true => "true",
|
26
|
+
"yes" => "true", "no" => "false"}
|
26
27
|
YES_NO = {"true" => "yes", "false" => "no"}
|
27
28
|
pis = KramdownRFC::ParameterSet.new({})
|
28
29
|
ps.arr("pi", false) do |pi, val|
|
@@ -36,7 +37,7 @@
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
pis.rest.each do |pi, val|
|
39
|
-
v = YES_NO[val] ||
|
40
|
+
v = YES_NO[val] || pis.escattr(val)
|
40
41
|
-%>
|
41
42
|
<?rfc <%=pi%>="<%=v%>"?>
|
42
43
|
<% end -%>
|
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.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.}
|
@@ -33,7 +33,7 @@ module KramdownRFC
|
|
33
33
|
%{#{an}="#{escattr(val)}"} if val
|
34
34
|
end
|
35
35
|
def attrs(*pns)
|
36
|
-
pns.map{ |pn| attr(pn) }.compact.join(" ")
|
36
|
+
pns.map{ |pn| attr(pn) if pn }.compact.join(" ")
|
37
37
|
end
|
38
38
|
def ele(pn, attr=nil, defcontent=nil, markdown=false)
|
39
39
|
val, an = van(pn)
|
@@ -65,5 +65,4 @@ module KramdownRFC
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
68
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
FOLD_COLUMNS = 69
|
2
|
+
RE_IDENT = /\A[A-Za-z0-9_]\z/
|
3
|
+
|
4
|
+
def fold8792_1(s, columns = FOLD_COLUMNS)
|
5
|
+
if s.index("\t")
|
6
|
+
warn "*** HT (\"TAB\") in text to be folded. Giving up."
|
7
|
+
return s
|
8
|
+
end
|
9
|
+
|
10
|
+
lines = s.lines.map(&:chomp)
|
11
|
+
did_fold = false
|
12
|
+
ix = 0
|
13
|
+
while li = lines[ix]
|
14
|
+
col = columns
|
15
|
+
if li[col].nil?
|
16
|
+
if li[-1] == "\\"
|
17
|
+
lines[ix..ix] = [li << "\\", ""]
|
18
|
+
ix += 1
|
19
|
+
end
|
20
|
+
ix += 1
|
21
|
+
else
|
22
|
+
did_fold = true
|
23
|
+
col -= 1 # space for "\\"
|
24
|
+
while li[col] == " " # can't start new line with " "
|
25
|
+
col -= 1
|
26
|
+
end
|
27
|
+
if col <= 0
|
28
|
+
warn "*** Cannot RFC8792-fold1 #{li.inspect}"
|
29
|
+
else
|
30
|
+
if RE_IDENT === li[col] # Don't split IDs
|
31
|
+
col2 = col
|
32
|
+
while col2 > 0 && RE_IDENT === li[col2-1]
|
33
|
+
col2 -= 1
|
34
|
+
end
|
35
|
+
if col2 > 0
|
36
|
+
col = col2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rest = li[col..-1]
|
40
|
+
indent = columns - rest.size
|
41
|
+
if li[-1] == "\\"
|
42
|
+
indent -= 1 # leave space for next round
|
43
|
+
end
|
44
|
+
if indent > 0
|
45
|
+
rest = " " * indent + rest
|
46
|
+
end
|
47
|
+
lines[ix..ix] = [li[0...col] << "\\", rest]
|
48
|
+
end
|
49
|
+
ix += 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if did_fold
|
54
|
+
lines[0...0] = ["=== NOTE: '\\' line wrapping per RFC 8792 ===", ""]
|
55
|
+
lines.map{|x| x << "\n"}.join
|
56
|
+
else
|
57
|
+
s
|
58
|
+
end
|
59
|
+
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
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.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: 2021-
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/kramdown-rfc/kdrfc-processor.rb
|
100
100
|
- lib/kramdown-rfc/parameterset.rb
|
101
101
|
- lib/kramdown-rfc/refxml.rb
|
102
|
+
- lib/kramdown-rfc/rfc8792.rb
|
102
103
|
- lib/kramdown-rfc2629.rb
|
103
104
|
homepage: http://github.com/cabo/kramdown-rfc2629
|
104
105
|
licenses:
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.2.
|
123
|
+
rubygems_version: 3.2.32
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: Kramdown extension for generating RFC 7749 XML.
|