kramdown-rfc2629 1.7.35 → 1.7.37
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/kramdown-rfc2629.gemspec +2 -1
- data/lib/kramdown-rfc/command.rb +44 -14
- data/lib/kramdown-rfc2629.rb +14 -3
- 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: a137034ca47a378411e22f6f1174a7e3bd38ec49602071dd1d1bdc9baae5dce7
|
|
4
|
+
data.tar.gz: 314a3eb7904262f07005244ad182557b60163e2dc60342ad50f82bc0d7e9c631
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2a53bae6614608fb60c8007d04a582d225ee45f846ae318b68111fa157ba81f9f96256b5729335083f55c4e823d3091af4ceb10e45f5af90d0b028894dcad1b
|
|
7
|
+
data.tar.gz: 52bbd44c2902ea00153d33668d4334d7206c413c6f45223ff1ce4006188868f22d78975918f5f1a8c56a78b079a7a8290c493826cead32c5439420a43fa5d6ac
|
data/kramdown-rfc2629.gemspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
|
3
|
-
s.version = '1.7.
|
|
3
|
+
s.version = '1.7.37'
|
|
4
|
+
|
|
4
5
|
s.summary = "Kramdown extension for generating RFCXML (RFC 799x)."
|
|
5
6
|
s.description = %{An RFCXML (RFC 799x) generating backend for Thomas Leitner's
|
|
6
7
|
"kramdown" markdown parser. Mostly useful for RFC writers.}
|
data/lib/kramdown-rfc/command.rb
CHANGED
|
@@ -25,10 +25,11 @@ def process_xml(s)
|
|
|
25
25
|
d.to_s
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def process_chunk(s, nested, dedent, fold, quote, xml, data)
|
|
28
|
+
def process_chunk(s, nested, dedent, range, fold, quote, xml, data)
|
|
29
29
|
process_includes(s) if nested
|
|
30
30
|
s = remove_indentation(s) if dedent
|
|
31
31
|
s = process_xml(s) if xml
|
|
32
|
+
s = s.lines[range].join if range
|
|
32
33
|
s = %{src="data:application/octet-stream;base64,#{[s].pack('m0')}"} if data
|
|
33
34
|
s = fold8792_1(s, *fold) if fold
|
|
34
35
|
s = add_quote(s) if quote
|
|
@@ -36,7 +37,7 @@ def process_chunk(s, nested, dedent, fold, quote, xml, data)
|
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def process_includes(input)
|
|
39
|
-
input.gsub!(/^\{::include((?:-[a-z0-9]+)*)\s+(.*?)\}/) {
|
|
40
|
+
input.gsub!(/^\{::include((?:-[a-z0-9.]+)*)\s+(.*?)\}/) {
|
|
40
41
|
include_flags = $1
|
|
41
42
|
fn = [$2]
|
|
42
43
|
chunks = false
|
|
@@ -45,6 +46,7 @@ def process_includes(input)
|
|
|
45
46
|
fold = false
|
|
46
47
|
quote = false
|
|
47
48
|
xml = false
|
|
49
|
+
range = false
|
|
48
50
|
data = false
|
|
49
51
|
include_flags.split("-") do |flag|
|
|
50
52
|
case flag
|
|
@@ -57,6 +59,10 @@ def process_includes(input)
|
|
|
57
59
|
dedent = true
|
|
58
60
|
when "xml"
|
|
59
61
|
xml = true
|
|
62
|
+
when /\Alines(\d*)\.\.(\.)?(\d*)\z/
|
|
63
|
+
range = Range.new($1.empty? ? nil : $1.to_i - 1, # compensate for
|
|
64
|
+
$3.empty? ? nil : $3.to_i - 1, # extra newline
|
|
65
|
+
$2)
|
|
60
66
|
when "data"
|
|
61
67
|
data = true
|
|
62
68
|
when /\Afold(\d*)(left(\d*))?(dry)?\z/
|
|
@@ -67,7 +73,7 @@ def process_includes(input)
|
|
|
67
73
|
fn = fn.flat_map{|n| Dir[n]}
|
|
68
74
|
fn = [fn.last] if flag == "last"
|
|
69
75
|
chunks = fn.map{ |f|
|
|
70
|
-
ret = process_chunk(File.read(f), nested, dedent, fold, quote, xml, data)
|
|
76
|
+
ret = process_chunk(File.read(f), nested, dedent, range, fold, quote, xml, data)
|
|
71
77
|
nested = false; dedent = false; fold = false; quote = false
|
|
72
78
|
ret
|
|
73
79
|
}
|
|
@@ -76,7 +82,7 @@ def process_includes(input)
|
|
|
76
82
|
end
|
|
77
83
|
end
|
|
78
84
|
chunks = fn.map{|f| File.read(f)} unless chunks # no all/last
|
|
79
|
-
chunks = chunks.map {|ch| process_chunk(ch, nested, dedent, fold, quote, xml, data)}
|
|
85
|
+
chunks = chunks.map {|ch| process_chunk(ch, nested, dedent, range, fold, quote, xml, data)}
|
|
80
86
|
chunks.join.chomp
|
|
81
87
|
}
|
|
82
88
|
end
|
|
@@ -192,21 +198,40 @@ NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]
|
|
|
192
198
|
|
|
193
199
|
NORMINFORM = { "!" => :normative, "?" => :informative }
|
|
194
200
|
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
|
|
202
|
+
# Handle several transitions of YAML API:
|
|
203
|
+
# * very early Ruby (no safe_load, before Ruby 2.1)
|
|
204
|
+
# * Ruby before 3.1 (safe_load, positional parameters)
|
|
205
|
+
# * Ruby 2.6 up (safe_load, keyword parameters)
|
|
206
|
+
def yaml_load_compat(input, *args)
|
|
197
207
|
if YAML.respond_to?(:safe_load)
|
|
198
208
|
begin
|
|
199
209
|
YAML.safe_load(input, *args)
|
|
200
210
|
rescue ArgumentError
|
|
201
|
-
YAML.safe_load(input, permitted_classes: args[0], permitted_symbols: args[1], aliases: args[2])
|
|
211
|
+
YAML.safe_load(input, permitted_classes: args[0], permitted_symbols: args[1], aliases: args[2], filename: args[3])
|
|
202
212
|
end
|
|
203
213
|
else
|
|
204
214
|
YAML.load(input)
|
|
205
215
|
end
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def yaml_diagnose(input, *args)
|
|
219
|
+
l = input.lines.to_a
|
|
220
|
+
(l.size-1).downto(0) do |nl|
|
|
221
|
+
yaml_load_compat(l[0...nl].join, *args) rescue next
|
|
222
|
+
warn "** YAML appears to be parsable up to line #{nl}"
|
|
223
|
+
return
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def yaml_load(input, *args)
|
|
228
|
+
begin
|
|
229
|
+
yaml_load_compat(input, *args)
|
|
230
|
+
rescue Psych::SyntaxError => e
|
|
231
|
+
warn "*** YAML syntax error: #{e}"
|
|
232
|
+
yaml_diagnose(input, *args) rescue nil
|
|
233
|
+
exit 65 # EX_DATAERR
|
|
234
|
+
end
|
|
210
235
|
end
|
|
211
236
|
|
|
212
237
|
def process_kramdown_options(coding_override = nil,
|
|
@@ -282,7 +307,7 @@ def read_erbfile
|
|
|
282
307
|
File.read(erbfilename, coding: "UTF-8")
|
|
283
308
|
end
|
|
284
309
|
|
|
285
|
-
def xml_from_sections(input)
|
|
310
|
+
def xml_from_sections(input, filename = "YAML header")
|
|
286
311
|
|
|
287
312
|
unless ENV["KRAMDOWN_NO_SOURCE"]
|
|
288
313
|
require 'kramdown-rfc/gzip-clone'
|
|
@@ -303,13 +328,13 @@ def xml_from_sections(input)
|
|
|
303
328
|
# the first section is a YAML with front matter parameters (don't put a label here)
|
|
304
329
|
# We put back the "---" plus gratuitous blank lines to hack the line number in errors
|
|
305
330
|
yaml_in = input[/---\s*/] << sections.shift[2]
|
|
331
|
+
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true, filename))
|
|
306
332
|
begin
|
|
307
333
|
require 'kramdown-rfc/yamlcheck'
|
|
308
334
|
KramdownRFC::YAMLcheck.check_dup_keys(yaml_in)
|
|
309
335
|
rescue => e
|
|
310
336
|
warn "** Cannot check for duplicate keys in YAML header (#{e})"
|
|
311
337
|
end
|
|
312
|
-
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
|
|
313
338
|
|
|
314
339
|
if v = ps[:v]
|
|
315
340
|
warn "*** unsupported RFCXML version #{v}" if v != 3
|
|
@@ -628,6 +653,11 @@ end
|
|
|
628
653
|
|
|
629
654
|
warn "*** v2 #{$options.v2.inspect} v3 #{$options.v3.inspect}" if $options.verbose
|
|
630
655
|
|
|
656
|
+
input_filename = ARGV.join(", ")
|
|
657
|
+
case input_filename
|
|
658
|
+
when "", "-"
|
|
659
|
+
input_filename = "<stdin>"
|
|
660
|
+
end
|
|
631
661
|
input = ARGF.read
|
|
632
662
|
input.scrub! do |c|
|
|
633
663
|
warn "*** replaced invalid UTF-8 byte sequence #{c.inspect} by U+FFFD REPLACEMENT CHARACTER"
|
|
@@ -654,7 +684,7 @@ end
|
|
|
654
684
|
|
|
655
685
|
if input =~ /\A---/ # this is a sectionized file
|
|
656
686
|
do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
|
|
657
|
-
input, options, coding_override = xml_from_sections(input)
|
|
687
|
+
input, options, coding_override = xml_from_sections(input, input_filename)
|
|
658
688
|
else
|
|
659
689
|
options = process_kramdown_options # all default
|
|
660
690
|
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
|
@@ -745,7 +745,7 @@ COLORS
|
|
|
745
745
|
"<![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]>")
|
|
746
746
|
if result1 # nest TXT in artset with SVG
|
|
747
747
|
retsvg = mk_artwork(artwork_attr, "svg",
|
|
748
|
-
result1.sub(/.*?<svg/m, "<svg"))
|
|
748
|
+
result1.sub(/.*?<svg/m, "<svg")) # , t == "mermaid")
|
|
749
749
|
retart = "<artset>#{retsvg}#{retart}</artset>"
|
|
750
750
|
end
|
|
751
751
|
"#{' '*indent}<figure#{el_html_attributes(el)}>#{retart}</figure>\n"
|
|
@@ -800,6 +800,11 @@ COLORS
|
|
|
800
800
|
($3.to_i if $2), # left 0 for '', nil if no "left"
|
|
801
801
|
$4] # dry
|
|
802
802
|
result = fix_unterminated_line(fold8792_1(trim_empty_lines_around(result), *fold)) # XXX
|
|
803
|
+
when /\Alines(\d*)\.\.(\.)?(\d*)\z/
|
|
804
|
+
range = Range.new($1.empty? ? nil : $1.to_i, # compensate for
|
|
805
|
+
$3.empty? ? nil : $3.to_i, # counting from 1
|
|
806
|
+
$2)
|
|
807
|
+
result = result.lines[range].join
|
|
803
808
|
when "yaml2json"
|
|
804
809
|
begin
|
|
805
810
|
y = YAML.safe_load(result, aliases: true, filename: loc_str)
|
|
@@ -844,8 +849,14 @@ COLORS
|
|
|
844
849
|
result
|
|
845
850
|
end
|
|
846
851
|
|
|
847
|
-
def mk_artwork(artwork_attr, typ, content)
|
|
848
|
-
|
|
852
|
+
def mk_artwork(artwork_attr, typ, content, use_data = false)
|
|
853
|
+
if use_data
|
|
854
|
+
warn "** using data URI for artwork type #{typ}"
|
|
855
|
+
data = %{data:application/octet-stream;base64,#{[content].pack('m0')}}
|
|
856
|
+
"<artwork #{html_attributes(artwork_attr.merge("type" => typ, "src" => data))}></artwork>"
|
|
857
|
+
else
|
|
858
|
+
"<artwork #{html_attributes(artwork_attr.merge("type" => typ))}>#{content}</artwork>"
|
|
859
|
+
end
|
|
849
860
|
end
|
|
850
861
|
|
|
851
862
|
def convert_blockquote(el, indent, opts)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kramdown-rfc2629
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.37
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carsten Bormann
|
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
224
|
- !ruby/object:Gem::Version
|
|
225
225
|
version: '0'
|
|
226
226
|
requirements: []
|
|
227
|
-
rubygems_version: 4.0.
|
|
227
|
+
rubygems_version: 4.0.8
|
|
228
228
|
specification_version: 4
|
|
229
229
|
summary: Kramdown extension for generating RFCXML (RFC 799x).
|
|
230
230
|
test_files: []
|