kramdown-rfc2629 1.4.14.pre → 1.4.19
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 +5 -1
- data/bin/kdrfc +26 -6
- data/bin/kramdown-rfc-cache-i-d-bibxml +1 -1
- data/bin/kramdown-rfc-cache-subseries-bibxml +1 -1
- data/bin/kramdown-rfc2629 +17 -5
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +18 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d0ef4b91bf819df60d48b12c30be152eab6a987ba2d88a3572bde42e180925
|
4
|
+
data.tar.gz: '09603840027889929894dfc79170f6f7d16a0e932cfe7b6dfc4d2d2501eb7f7d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35f806b212b3f6e321614752853dc73ed351f1119c208b7fd83cbd471e3d64e40145b3af19a999a2e2e403a1ff780c5b12baef21c6b44e7e4f4ed8e434610e17
|
7
|
+
data.tar.gz: cb0ddd23e2ced4bda22a095d08926dbbaf6f12a8605faf53289a422c8e1bd2b9d5a9a01a350d88c5843c12ff0a0be4098425403507771d5ba526126bc130bb7d
|
data/README.md
CHANGED
@@ -317,6 +317,10 @@ Note that this feature does not play well with the CI (continuous
|
|
317
317
|
integration) support in Martin Thomson's [I-D Template][], as that may
|
318
318
|
not have the tools installed in its docker instance.
|
319
319
|
|
320
|
+
More details have been collected on the [wiki][svg].
|
321
|
+
|
322
|
+
[svg]: https://github.com/cabo/kramdown-rfc2629/wiki/SVG
|
323
|
+
|
320
324
|
(1.2.9:)
|
321
325
|
The YAML header now allows specifying [kramdown_options][].
|
322
326
|
|
@@ -558,7 +562,7 @@ remaining 20 % some more, but that hasn't been done.
|
|
558
562
|
|
559
563
|
If you have XML, there is an experimental upconverter that does 99 %
|
560
564
|
of the work. Please [contact the
|
561
|
-
author](mailto:cabo@tzi.org?subject=Markdown
|
565
|
+
author](mailto:cabo@tzi.org?subject=Markdown%20for%20RFCXML) if you want
|
562
566
|
to try it.
|
563
567
|
|
564
568
|
Actually, if the XML was generated by kramdown-rfc2629, you can simply
|
data/bin/kdrfc
CHANGED
@@ -6,13 +6,15 @@ require 'open3'
|
|
6
6
|
# try to get this from gemspec.
|
7
7
|
KDRFC_VERSION=Gem.loaded_specs["kramdown-rfc2629"].version rescue "unknown-version"
|
8
8
|
|
9
|
+
KDRFC_PREPEND = [ENV["KDRFC_PREPEND"]].compact
|
10
|
+
|
9
11
|
def v3_flag?
|
10
12
|
$options.v3 ? ["--v3"] : []
|
11
13
|
end
|
12
14
|
|
13
15
|
def process_mkd(input, output)
|
14
16
|
warn "* converting locally from markdown #{input} to xml #{output}" if $options.verbose
|
15
|
-
o, s = Open3.capture2("kramdown-rfc2629", *v3_flag?, input)
|
17
|
+
o, s = Open3.capture2(*KDRFC_PREPEND, "kramdown-rfc2629", *v3_flag?, input)
|
16
18
|
if s.success?
|
17
19
|
File.open(output, "w") do |fo|
|
18
20
|
fo.print(o)
|
@@ -41,7 +43,7 @@ end
|
|
41
43
|
def process_xml_locally(input, output, *flags)
|
42
44
|
warn "* converting locally from xml #{input} to txt #{output}" if $options.verbose
|
43
45
|
begin
|
44
|
-
o, s = Open3.capture2("xml2rfc", *v3_flag?, *flags, input)
|
46
|
+
o, s = Open3.capture2(*KDRFC_PREPEND, "xml2rfc", *v3_flag?, *flags, input)
|
45
47
|
puts o
|
46
48
|
if s.success?
|
47
49
|
warn "* #{output} written" if $options.verbose
|
@@ -51,19 +53,37 @@ def process_xml_locally(input, output, *flags)
|
|
51
53
|
end
|
52
54
|
rescue Errno::ENOENT
|
53
55
|
warn "*** falling back to remote processing" if $options.verbose
|
54
|
-
process_xml_remotely(input, output)
|
56
|
+
process_xml_remotely(input, output, *flags)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
60
|
XML2RFC_WEBSERVICE = ENV["KRAMDOWN_XML2RFC_WEBSERVICE"] ||
|
59
61
|
'http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc-dev.cgi'
|
60
62
|
|
63
|
+
MODE_AS_FORMAT = {
|
64
|
+
nil => { # v2
|
65
|
+
"--text" => "txt/ascii",
|
66
|
+
"--html" => "html/ascii",
|
67
|
+
},
|
68
|
+
true => { # v3
|
69
|
+
"--text" => "txt/v3ascii",
|
70
|
+
"--html" => "html/v3ascii",
|
71
|
+
"--v2v3" => "v3xml/ascii",
|
72
|
+
}
|
73
|
+
}
|
61
74
|
|
62
|
-
def process_xml_remotely(input, output)
|
75
|
+
def process_xml_remotely(input, output, *flags)
|
63
76
|
warn "* converting remotely from xml #{input} to txt #{output}" if $options.verbose
|
77
|
+
format = flags[0] || "--text"
|
78
|
+
# warn [:V3, $options.v3].inspect
|
79
|
+
maf = MODE_AS_FORMAT[$options.v3][format]
|
80
|
+
unless maf
|
81
|
+
warn "*** don't know how to convert remotely from xml #{input} to txt #{output}"
|
82
|
+
exit(1)
|
83
|
+
end
|
64
84
|
url = URI(XML2RFC_WEBSERVICE)
|
65
85
|
req = Net::HTTP::Post.new(url)
|
66
|
-
form = [["modeAsFormat",
|
86
|
+
form = [["modeAsFormat", maf],
|
67
87
|
["type", "binary"],
|
68
88
|
["input", File.open(input),
|
69
89
|
{filename: "input.xml",
|
@@ -127,7 +147,7 @@ BANNER
|
|
127
147
|
opts.on("-p", "--[no-]prep", "Convert xml to prepped xml") do |v|
|
128
148
|
$options.prep = v
|
129
149
|
end
|
130
|
-
opts.on("-P", "--[no-]pdf", "Convert xml to PDF") do |v|
|
150
|
+
opts.on("-P", "-f", "--[no-]pdf", "Convert xml to PDF") do |v|
|
131
151
|
$options.pdf = v
|
132
152
|
end
|
133
153
|
opts.on("-c", "--[no-]convert", "Convert xml to v3 xml") do |v|
|
data/bin/kramdown-rfc2629
CHANGED
@@ -83,7 +83,7 @@ def do_the_tls_dance
|
|
83
83
|
end
|
84
84
|
|
85
85
|
RE_NL = /(?:\n|\r|\r\n)/
|
86
|
-
RE_SECTION = /---(
|
86
|
+
RE_SECTION = /---(?: +(\w+)(-?))?\s*#{RE_NL}(.*?#{RE_NL})(?=---(?:\s+\w+-?)?\s*#{RE_NL}|\Z)/m
|
87
87
|
|
88
88
|
NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
|
89
89
|
|
@@ -195,6 +195,7 @@ def xml_from_sections(input)
|
|
195
195
|
sechash = Hash.new{ |h,k| h[k] = ""}
|
196
196
|
snames = [] # a stack of section names
|
197
197
|
sections.each do |sname, nmdflag, text|
|
198
|
+
# warn [:SNAME, sname, nmdflag, text[0..10]].inspect
|
198
199
|
nmdin, nmdout = {
|
199
200
|
"-" => ["", ""], # stay in nomarkdown
|
200
201
|
"" => NMDTAGS, # pop out temporarily
|
@@ -306,7 +307,7 @@ def xml_from_sections(input)
|
|
306
307
|
[:normative, :informative].each do |sn|
|
307
308
|
if refs = ps[sn]
|
308
309
|
refs.each do |k, v|
|
309
|
-
href =
|
310
|
+
href = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(k)
|
310
311
|
kramdown_options[:link_defs][k] = ["##{href}", nil] # allow [RFC2119] in addition to {{RFC2119}}
|
311
312
|
|
312
313
|
bibref = anchor_to_bibref[k] || k
|
@@ -328,7 +329,7 @@ def xml_from_sections(input)
|
|
328
329
|
if bts && !v.delete("override")
|
329
330
|
warn "*** warning: explicit settings completely override canned bibxml in reference #{k}"
|
330
331
|
end
|
331
|
-
sechash[sn.to_s] << KramdownRFC::ref_to_xml(
|
332
|
+
sechash[sn.to_s] << KramdownRFC::ref_to_xml(href, v)
|
332
333
|
end
|
333
334
|
end
|
334
335
|
end
|
@@ -363,7 +364,7 @@ def bibtagsys(bib, anchor=nil, stand_alone=true)
|
|
363
364
|
elsif bib =~ /\A([-A-Z0-9]+)\./ &&
|
364
365
|
(xro = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_MAP[$1])
|
365
366
|
dir, _ttl, rewrite_anchor = xro
|
366
|
-
bib1 =
|
367
|
+
bib1 = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(bib)
|
367
368
|
if anchor && bib1 != anchor
|
368
369
|
if rewrite_anchor
|
369
370
|
a = %{?anchor=#{anchor}}
|
@@ -461,7 +462,18 @@ if coding_override
|
|
461
462
|
input = input.encode(Encoding.find(coding_override), fallback: FALLBACK)
|
462
463
|
end
|
463
464
|
|
465
|
+
# 1.4.17: because of UTF-8 bibxml files, kramdown always needs to see UTF-8 (!)
|
466
|
+
if input.encoding != Encoding::UTF_8
|
467
|
+
input = input.encode(Encoding::UTF_8)
|
468
|
+
end
|
469
|
+
|
464
470
|
# warn "options: #{options.inspect}"
|
465
471
|
doc = Kramdown::Document.new(input, options)
|
466
472
|
$stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
|
467
|
-
|
473
|
+
output = doc.to_rfc2629
|
474
|
+
|
475
|
+
if coding_override
|
476
|
+
output = output.encode(Encoding.find(coding_override), fallback: FALLBACK)
|
477
|
+
end
|
478
|
+
|
479
|
+
puts output
|
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.4.
|
3
|
+
s.version = '1.4.19'
|
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
@@ -42,7 +42,7 @@ module Kramdown
|
|
42
42
|
@block_parsers.unshift(:block_pi)
|
43
43
|
end
|
44
44
|
|
45
|
-
XREF_BASE =
|
45
|
+
XREF_BASE = /#{REXML::XMLTokens::NAME_CHAR}+/ # a token for a reference
|
46
46
|
XREF_TXT = /(?:[^\(]|\([^\)]*\))+/ # parenthesized text
|
47
47
|
XREF_RE = /#{XREF_BASE}(?: \(#{XREF_TXT}\))?/
|
48
48
|
XREF_RE_M = /\A(#{XREF_BASE})(?: \((#{XREF_TXT})\))?/ # matching version of XREF_RE
|
@@ -51,6 +51,11 @@ module Kramdown
|
|
51
51
|
XREF_ANY = /(?:#{XREF_SINGLE}|#{XREF_MULTI})/
|
52
52
|
SECTIONS_RE = /(?:#{XREF_ANY} and )?#{XREF_ANY}/
|
53
53
|
|
54
|
+
def self.idref_cleanup(href)
|
55
|
+
# can't start an IDREF with a number or reserved start
|
56
|
+
href.gsub(/\A(?:[0-9]|section-|u-|figure-|table-|iref-)/) { "_#{$&}" }
|
57
|
+
end
|
58
|
+
|
54
59
|
def handle_bares(s, attr, format, href, last_join = nil)
|
55
60
|
if s.match(/\A(#{XREF_ANY}) and (#{XREF_ANY})\z/)
|
56
61
|
handle_bares($1, {}, nil, href, " and ")
|
@@ -120,7 +125,7 @@ module Kramdown
|
|
120
125
|
when /\A(.*) \((#{SECTIONS_RE})\)\z/
|
121
126
|
href = $1
|
122
127
|
handle_bares($2, attr, "parens", href)
|
123
|
-
when /\A(
|
128
|
+
when /\A(#{XREF_BASE})<(.+)\z/
|
124
129
|
href = $2
|
125
130
|
attr['section'] = $1
|
126
131
|
attr['sectionFormat'] = 'bare'
|
@@ -132,11 +137,11 @@ module Kramdown
|
|
132
137
|
attr['format'] = 'counter'
|
133
138
|
end
|
134
139
|
end
|
135
|
-
if href.match(XREF_RE_M)
|
140
|
+
if href.match(/#{XREF_RE_M}\z/)
|
136
141
|
href = $1
|
137
142
|
attr['text'] = $2
|
138
143
|
end
|
139
|
-
href =
|
144
|
+
href = self.class.idref_cleanup(href)
|
140
145
|
attr['target'] = href
|
141
146
|
el = Element.new(:xref, nil, attr)
|
142
147
|
end
|
@@ -212,10 +217,10 @@ module Kramdown
|
|
212
217
|
def rfc2629_fix
|
213
218
|
if a = attr
|
214
219
|
if anchor = a.delete('id')
|
215
|
-
a['anchor'] = anchor
|
220
|
+
a['anchor'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
|
216
221
|
end
|
217
222
|
if anchor = a.delete('href')
|
218
|
-
a['target'] = anchor
|
223
|
+
a['target'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
|
219
224
|
end
|
220
225
|
attr.keys.each do |k|
|
221
226
|
if (d = k.gsub(/_(.|$)/) { $1.upcase }) != k or d = STUDLY_ATTR_MAP[k]
|
@@ -251,7 +256,10 @@ module Kramdown
|
|
251
256
|
require 'net/http/persistent'
|
252
257
|
$http = Net::HTTP::Persistent.new name: 'kramdown-rfc'
|
253
258
|
rescue Exception => e
|
254
|
-
warn "**
|
259
|
+
warn "** Not using persistent HTTP -- #{e}"
|
260
|
+
warn "** To silence this message and get full speed, try:"
|
261
|
+
warn "** gem install net-http-persistent"
|
262
|
+
warn "** If this doesn't work, you can ignore this warning."
|
255
263
|
end
|
256
264
|
end
|
257
265
|
|
@@ -917,6 +925,7 @@ COLORS
|
|
917
925
|
],
|
918
926
|
"W3C" => "bibxml4",
|
919
927
|
"3GPP" => "bibxml5",
|
928
|
+
"SDO-3GPP" => "bibxml5",
|
920
929
|
"ANSI" => "bibxml2",
|
921
930
|
"CCITT" => "bibxml2",
|
922
931
|
"FIPS" => "bibxml2",
|
@@ -955,7 +964,7 @@ COLORS
|
|
955
964
|
warn "*** missing anchor for '#{src}'"
|
956
965
|
src
|
957
966
|
)
|
958
|
-
anchor.
|
967
|
+
anchor = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
|
959
968
|
anchor.gsub!('/', '_') # should take out all illegals
|
960
969
|
to_insert = ""
|
961
970
|
src.scan(/(W3C|3GPP|[A-Z-]+)[.]?([A-Za-z_0-9.\/\+-]+)/) do |t, n|
|
@@ -1024,7 +1033,7 @@ COLORS
|
|
1024
1033
|
# "\n#{' '*indent}<cref>\n#{inner(el.value, indent, opts).rstrip}\n#{' '*indent}</cref>"
|
1025
1034
|
content = inner(el.value, indent, opts).strip
|
1026
1035
|
content = escape_html(content.sub(/\A<t>(.*)<\/t>\z/m) {$1}, :text) # text only...
|
1027
|
-
name = el.options[:name]
|
1036
|
+
name = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(el.options[:name])
|
1028
1037
|
while @footnote_names_in_use[name] do
|
1029
1038
|
if name =~ /:\d+\z/
|
1030
1039
|
name.succ!
|
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.4.
|
4
|
+
version: 1.4.19
|
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-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -98,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: 2.3.0
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubygems_version: 3.2.15
|
106
106
|
signing_key:
|