kramdown-rfc2629 1.7.39 → 1.7.41
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/README.md +3 -2
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc/command.rb +2 -5
- data/lib/kramdown-rfc/rfc8792.rb +23 -5
- data/lib/kramdown-rfc2629.rb +10 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b32b21ea6b67eda069c4bb1c102f7e505b91ad149970e76ba182080111242a0
|
|
4
|
+
data.tar.gz: c3236319bb5e66f0f39f65d3b1f174d87fca1b85a22ca79e8b4067a98eb2b450
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3457a313f0b84244f822de4ebc11feb12575db86c10647cfad6a6a0fae91340e1252bf0821959eafce8fc65ca31131b11ae9d3ddf4ac258c3c1d49a1bdcc27ed
|
|
7
|
+
data.tar.gz: d3c8f5fc6d5bf4fe947cb27a4304050682ec7dd14b4199644121a668ddc58f1bba4ff7116f9660b2f22bb0d33ce880b7b987d61a1ce1edfd7f602e372dfbddcb
|
data/README.md
CHANGED
|
@@ -12,10 +12,11 @@ Who would care? Anybody who is writing Internet-Drafts and RFCs in
|
|
|
12
12
|
the [IETF][] and prefers (or has co-authors who prefer) to do part of
|
|
13
13
|
their work in markdown.
|
|
14
14
|
|
|
15
|
-
kramdown-rfc is documented on this page,
|
|
16
|
-
[the wiki][].
|
|
15
|
+
kramdown-rfc is documented on this page, as well as on
|
|
16
|
+
[the wiki][] and via a "[Rosetta Stone]" maintained by the RFC Production Center.
|
|
17
17
|
|
|
18
18
|
[the wiki]: https://github.com/cabo/kramdown-rfc/wiki
|
|
19
|
+
[Rosetta Stone]: https://authors.ietf.org/en/rfcxml-markdown-syntax-tables
|
|
19
20
|
|
|
20
21
|
# Usage
|
|
21
22
|
|
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.7.
|
|
3
|
+
s.version = '1.7.41'
|
|
4
4
|
s.summary = "Kramdown extension for generating RFCXML (RFC 799x)."
|
|
5
5
|
s.description = %{An RFCXML (RFC 799x) generating backend for Thomas Leitner's
|
|
6
6
|
"kramdown" markdown parser. Mostly useful for RFC writers.}
|
data/lib/kramdown-rfc/command.rb
CHANGED
|
@@ -65,11 +65,8 @@ def process_includes(input)
|
|
|
65
65
|
$2)
|
|
66
66
|
when "data"
|
|
67
67
|
data = true
|
|
68
|
-
when
|
|
69
|
-
|
|
70
|
-
columns = md[:columns].to_i
|
|
71
|
-
left = md[:spaces].to_i if md[:left]
|
|
72
|
-
fold = [columns, left, md[:dry], md[:hard]]
|
|
68
|
+
when ::FOLD8792_PROC_RE
|
|
69
|
+
fold = fold8792_options(Regexp.last_match)
|
|
73
70
|
when "all", "last"
|
|
74
71
|
fn_in = fn
|
|
75
72
|
fn = fn.flat_map{|n| Dir[n]}
|
data/lib/kramdown-rfc/rfc8792.rb
CHANGED
|
@@ -22,6 +22,13 @@ end
|
|
|
22
22
|
|
|
23
23
|
FOLD_MSG = "NOTE: '\\' line wrapping per RFC 8792".freeze
|
|
24
24
|
UNFOLD_RE = /\A.*#{FOLD_MSG.sub("\\", "(\\\\\\\\\\\\\\\\?)")}.*\n\r?\n/
|
|
25
|
+
# use indent as preferred synonym over smart
|
|
26
|
+
FOLD8792_PROC_RE = /\Afold(?<columns>\d*)(?<hard>hard)?(?:(?<indent_type>left|smart|indent)(?<spaces>\d*))?(?<dry>dry)?\z/
|
|
27
|
+
|
|
28
|
+
def fold8792_options(md)
|
|
29
|
+
indent_type = md[:indent_type].to_sym if md[:indent_type]
|
|
30
|
+
[md[:columns].to_i, indent_type, (md[:spaces] || 0).to_i, md[:dry], md[:hard]]
|
|
31
|
+
end
|
|
25
32
|
|
|
26
33
|
def unfold8792(s)
|
|
27
34
|
if s =~ UNFOLD_RE
|
|
@@ -44,7 +51,7 @@ MIN_FOLD_COLUMNS = FOLD_MSG.size
|
|
|
44
51
|
FOLD_COLUMNS = 69
|
|
45
52
|
RE_IDENT = /\A[A-Za-z0-9_]\z/
|
|
46
53
|
|
|
47
|
-
def fold8792_1(s, columns = FOLD_COLUMNS,
|
|
54
|
+
def fold8792_1(s, columns = FOLD_COLUMNS, indent_type = nil, indent_spaces = 0, dry = false, hard = false)
|
|
48
55
|
if s.index("\t")
|
|
49
56
|
warn "*** HT (\"TAB\") in text to be folded. Giving up."
|
|
50
57
|
return s
|
|
@@ -61,6 +68,7 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
|
|
|
61
68
|
|
|
62
69
|
lines = s.lines.map(&:chomp)
|
|
63
70
|
did_fold = false
|
|
71
|
+
smart_indent = nil
|
|
64
72
|
ix = 0
|
|
65
73
|
while li = lines[ix]
|
|
66
74
|
col = columns
|
|
@@ -69,16 +77,26 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
|
|
|
69
77
|
lines[ix..ix] = [li << "\\", ""]
|
|
70
78
|
ix += 1
|
|
71
79
|
end
|
|
80
|
+
smart_indent = nil
|
|
72
81
|
ix += 1
|
|
73
82
|
else
|
|
74
83
|
did_fold = true
|
|
75
|
-
|
|
84
|
+
left_indent =
|
|
85
|
+
case indent_type
|
|
86
|
+
when :left
|
|
87
|
+
indent_spaces
|
|
88
|
+
when :smart, :indent
|
|
89
|
+
smart_indent ||= li[/\A */].size + indent_spaces
|
|
90
|
+
end
|
|
91
|
+
min_indent = left_indent || 0
|
|
76
92
|
col -= 1 # space for "\\"
|
|
77
93
|
while li[col] == " " # can't start new line with " "
|
|
78
94
|
col -= 1
|
|
79
95
|
end
|
|
80
96
|
if col <= min_indent
|
|
81
|
-
|
|
97
|
+
indent_msg = "with indent #{min_indent}" if indent_type
|
|
98
|
+
warn "*** Cannot RFC8792-fold1 to #{columns} cols #{indent_msg} |#{li.inspect}|"
|
|
99
|
+
smart_indent = nil
|
|
82
100
|
else
|
|
83
101
|
if !hard && RE_IDENT === li[col] # Don't split IDs
|
|
84
102
|
col2 = col
|
|
@@ -90,8 +108,8 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
|
|
|
90
108
|
end
|
|
91
109
|
end
|
|
92
110
|
rest = li[col..-1]
|
|
93
|
-
indent =
|
|
94
|
-
if !
|
|
111
|
+
indent = left_indent || columns - rest.size
|
|
112
|
+
if !left_indent && li[-1] == "\\"
|
|
95
113
|
indent -= 1 # leave space for next round
|
|
96
114
|
end
|
|
97
115
|
if indent > 0
|
data/lib/kramdown-rfc2629.rb
CHANGED
|
@@ -109,8 +109,8 @@ module Kramdown
|
|
|
109
109
|
XREF_TXT = /(?:[^\(]|\([^\)]*\))+/ # parenthesized text
|
|
110
110
|
XREF_RE = /#{XREF_BASE}(?: \(#{XREF_TXT}\))?/
|
|
111
111
|
XREF_RE_M = /\A(#{XREF_BASE})(?: \((#{XREF_TXT})\))?/ # matching version of XREF_RE
|
|
112
|
-
XREF_SINGLE = /(?:Section|Appendix) #{XREF_RE}/
|
|
113
|
-
XREF_MULTI = /(?:Sections|Appendices) (?:#{XREF_RE}, )*#{XREF_RE},? and #{XREF_RE}/
|
|
112
|
+
XREF_SINGLE = /(?:Section|Appendix|Table|Figure) #{XREF_RE}/
|
|
113
|
+
XREF_MULTI = /(?:Sections|Appendices|Tables|Figures) (?:#{XREF_RE}, )*#{XREF_RE},? and #{XREF_RE}/
|
|
114
114
|
XREF_ANY = /(?:#{XREF_SINGLE}|#{XREF_MULTI})/
|
|
115
115
|
SECTIONS_RE = /(?:#{XREF_ANY} and )?#{XREF_ANY}/
|
|
116
116
|
|
|
@@ -138,6 +138,8 @@ module Kramdown
|
|
|
138
138
|
return
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
reftype = s.match(/\A\w+/).to_s
|
|
142
|
+
issection = /[SA]/ =~ reftype[0]
|
|
141
143
|
href = href.split(' ')[0] # Remove any trailing (...)
|
|
142
144
|
target1, target2 = href.split("@", 2)
|
|
143
145
|
multi = last_join != nil
|
|
@@ -146,7 +148,7 @@ module Kramdown
|
|
|
146
148
|
m = s.match(/\A#{XREF_RE_M}(, (?:and )?| and )?/)
|
|
147
149
|
break if not m
|
|
148
150
|
|
|
149
|
-
if not multi and not m[2] and not m[3] and not target2
|
|
151
|
+
if not multi and not m[2] and not m[3] and not target2 and issection
|
|
150
152
|
# Modify |attr| if there is a single reference. This can only be
|
|
151
153
|
# used if there is only one section reference and the section part
|
|
152
154
|
# has no title.
|
|
@@ -165,6 +167,9 @@ module Kramdown
|
|
|
165
167
|
s[m[0]] = ''
|
|
166
168
|
|
|
167
169
|
attr1 = { 'target' => target1, 'section' => m[1], 'sectionFormat' => 'bare', 'text' => m[2] }
|
|
170
|
+
if !issection
|
|
171
|
+
attr1['relative'] = "##{reftype.downcase.chomp('s')}-#{m[1]}"
|
|
172
|
+
end
|
|
168
173
|
@tree.children << Element.new(:xref, nil, attr1)
|
|
169
174
|
andof = m[3] || last_join || " of "
|
|
170
175
|
if andof == " of " && target2
|
|
@@ -795,11 +800,8 @@ COLORS
|
|
|
795
800
|
case proc
|
|
796
801
|
when "dedent"
|
|
797
802
|
result = remove_indentation(result)
|
|
798
|
-
when
|
|
799
|
-
|
|
800
|
-
columns = md[:columns].to_i
|
|
801
|
-
left = md[:spaces].to_i if md[:left]
|
|
802
|
-
fold = [columns, left, md[:dry], md[:hard]]
|
|
803
|
+
when ::FOLD8792_PROC_RE
|
|
804
|
+
fold = fold8792_options(Regexp.last_match)
|
|
803
805
|
result = fix_unterminated_line(fold8792_1(trim_empty_lines_around(result), *fold)) # XXX
|
|
804
806
|
when /\Alines(\d*)\.\.(\.)?(\d*)\z/
|
|
805
807
|
range = Range.new($1.empty? ? nil : $1.to_i, # compensate for
|