kramdown-rfc2629 1.3.20 → 1.3.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +51 -2
- 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: 34bc0c22021d827ebe3c42abda25c3255a6f9902fb8ab94cb7b758c29119016b
|
4
|
+
data.tar.gz: 5e457122aa29c8f2ffac9db511ebc50c036b56d170879e8f9cbd46477099f81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a397ece10c7c210ea7231e35ea0f949146db5fce32799a1b4bbb91fa59f3bfe7fda9d7b8e3a40127c426cecdd8b304a1370e5f60934ab8bc7af1c94e466518
|
7
|
+
data.tar.gz: 0b22b30f1ca35a27b27d671b2b081c2881d10388f50abffb079c8af506e0ac706f6bf47f3d19d7c20c52029d1654fe854fc3c1098fb0e80aba8edd9cdfac5ede
|
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.21'
|
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
@@ -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 ![!](target) or ![ ](target)
|
@@ -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
|
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.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|