kramdown-rfc2629 1.6.32 → 1.6.34
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfdd6b2626b4919b9f19421d90541b9f7ec2cf8862e18c3ae5c8c8ba7bf425ba
|
4
|
+
data.tar.gz: 7d5a91368fa1aa42e189fb6b9dccd4fbe4439f07ff11833fb02104bf73bdbd94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b070e6f03fce066242187858977e9a2a6e91ebc12859a6f1571abe3e487681b4fbb85e470c6a52207ec85dcebfce039a8d201bdbe86c70c0af5ddda83250a1f
|
7
|
+
data.tar.gz: 6fcc90e3ee7ab1daec870b0b0c704c04108bb6a398a733609ba331bdd0106464623ee6b17a3478c8fab972068b193a9c285b5e7488a866aba888e36e464fd27d
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
require 'rexml/document'
|
5
|
+
require 'kramdown-rfc/rexml-formatters-conservative'
|
5
6
|
require 'kramdown-rfc/svg-id-cleanup'
|
6
7
|
|
7
8
|
def svg_clean_ids(s)
|
@@ -10,7 +11,10 @@ def svg_clean_ids(s)
|
|
10
11
|
|
11
12
|
svg_id_cleanup(d)
|
12
13
|
|
13
|
-
|
14
|
+
tr = REXML::Formatters::Conservative.new
|
15
|
+
o = ''
|
16
|
+
tr.write(d, o)
|
17
|
+
o
|
14
18
|
rescue => detail
|
15
19
|
warn "*** Can't clean SVG: #{detail}"
|
16
20
|
d.to_s
|
@@ -3,6 +3,7 @@ require 'rexml/document' # for SVG and bibxml acrobatics
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'shellwords'
|
5
5
|
require 'fileutils'
|
6
|
+
require_relative '../lib/kramdown-rfc/rfc8792'
|
6
7
|
|
7
8
|
def clean(s)
|
8
9
|
s.gsub!(/\//, ":")
|
@@ -12,6 +13,7 @@ end
|
|
12
13
|
|
13
14
|
target = nil
|
14
15
|
dir = nil
|
16
|
+
unfold = true
|
15
17
|
targets = [:list, :files, :zip, :yaml]
|
16
18
|
require 'optparse'
|
17
19
|
begin
|
@@ -23,6 +25,9 @@ begin
|
|
23
25
|
opts.on("-dDIR", "--dir=DIR", "Target directory (default: sourcecode)") do |v|
|
24
26
|
dir = v
|
25
27
|
end
|
28
|
+
opts.on("-f", "--[no-]unfold", "RFC8972-unfold (default: yes)") do |v|
|
29
|
+
unfold = v
|
30
|
+
end
|
26
31
|
end
|
27
32
|
op.parse!
|
28
33
|
rescue Exception => e
|
@@ -56,7 +61,7 @@ REXML::XPath.each(d.root, "//sourcecode|//artwork") do |x|
|
|
56
61
|
else
|
57
62
|
taken[ty][name] = ''
|
58
63
|
end
|
59
|
-
taken[ty][name] << x.text
|
64
|
+
taken[ty][name] << handle_artwork_sourcecode(x.text, unfold)
|
60
65
|
end
|
61
66
|
end
|
62
67
|
|
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.6.
|
3
|
+
s.version = '1.6.34'
|
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.}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module REXML
|
4
|
+
module Formatters
|
5
|
+
# The Conservative formatter writes an XML document that parses to an
|
6
|
+
# identical document as the source document. This means that no extra
|
7
|
+
# whitespace nodes are inserted, and whitespace within text nodes is
|
8
|
+
# preserved. Attributes are not sorted.
|
9
|
+
class Conservative < Default
|
10
|
+
def initialize
|
11
|
+
@indentation = 0
|
12
|
+
@level = 0
|
13
|
+
@ie_hack = false
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
def write_element( node, output )
|
18
|
+
output << "<#{node.expanded_name}"
|
19
|
+
|
20
|
+
node.attributes.each_attribute do |attr|
|
21
|
+
output << " "
|
22
|
+
attr.write( output )
|
23
|
+
end unless node.attributes.empty?
|
24
|
+
|
25
|
+
if node.children.empty?
|
26
|
+
output << "/"
|
27
|
+
else
|
28
|
+
output << ">"
|
29
|
+
node.children.each { |child|
|
30
|
+
write( child, output )
|
31
|
+
}
|
32
|
+
output << "</#{node.expanded_name}"
|
33
|
+
end
|
34
|
+
output << ">"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/kramdown-rfc/rfc8792.rb
CHANGED
@@ -6,8 +6,40 @@ def remove_indentation(s)
|
|
6
6
|
l.map {|li| li.sub(/^ {0,#{indent}}/, "")}.join
|
7
7
|
end
|
8
8
|
|
9
|
+
def trim_empty_lines_around(s) # this deletes the trailing newline, which may need to be reconstructed
|
10
|
+
s.sub(/\A(\r?\n)*/, '').sub(/(\r?\n)*\z/, '')
|
11
|
+
end
|
12
|
+
|
13
|
+
def fix_unterminated_line(s)
|
14
|
+
s.sub(/[^\n]\z/) { "#$&\n" } # XXX
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_artwork_sourcecode(s, unfold = true)
|
18
|
+
s = trim_empty_lines_around(s)
|
19
|
+
s = unfold8792(s) if unfold
|
20
|
+
fix_unterminated_line(s)
|
21
|
+
end
|
9
22
|
|
10
23
|
FOLD_MSG = "NOTE: '\\' line wrapping per RFC 8792".freeze
|
24
|
+
UNFOLD_RE = /\A.*#{FOLD_MSG.sub("\\", "(\\\\\\\\\\\\\\\\?)")}.*\n\r?\n/
|
25
|
+
|
26
|
+
def unfold8792(s)
|
27
|
+
if s =~ UNFOLD_RE
|
28
|
+
indicator = $1
|
29
|
+
s = $'
|
30
|
+
sub = case indicator
|
31
|
+
when "\\"
|
32
|
+
s.gsub!(/\\\n[ \t]*/, '')
|
33
|
+
when "\\\\"
|
34
|
+
s.gsub!(/\\\n[ \t]*\\/, '')
|
35
|
+
else
|
36
|
+
fail "indicator" # Cannot happen
|
37
|
+
end
|
38
|
+
warn "** encountered RFC 8792 header without folded lines" unless sub
|
39
|
+
end
|
40
|
+
s
|
41
|
+
end
|
42
|
+
|
11
43
|
MIN_FOLD_COLUMNS = FOLD_MSG.size
|
12
44
|
FOLD_COLUMNS = 69
|
13
45
|
RE_IDENT = /\A[A-Za-z0-9_]\z/
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -696,7 +696,7 @@ COLORS
|
|
696
696
|
fold = [$1.to_i, # col 0 for ''
|
697
697
|
($3.to_i if $2), # left 0 for '', nil if no "left"
|
698
698
|
$4] # dry
|
699
|
-
result = fold8792_1(result, *fold)
|
699
|
+
result = fix_unterminated_line(fold8792_1(trim_empty_lines_around(result), *fold)) # XXX
|
700
700
|
when "yaml2json"
|
701
701
|
begin
|
702
702
|
y = YAML.safe_load(result, aliases: true, filename: loc_str)
|
@@ -714,16 +714,19 @@ COLORS
|
|
714
714
|
preprocs.each do |proc|
|
715
715
|
result = sourcecode_proc(proc, loc_str, result)
|
716
716
|
end if preprocs
|
717
|
+
check_input = result
|
717
718
|
checks.each do |check|
|
718
719
|
case check
|
720
|
+
when "skipheader"
|
721
|
+
check_input = handle_artwork_sourcecode(check_input).sub(/.*?\n\n/m, '')
|
719
722
|
when "json"
|
720
|
-
#
|
723
|
+
# check for 8792; undo if needed:
|
721
724
|
begin
|
722
|
-
JSON.load(
|
725
|
+
JSON.load(handle_artwork_sourcecode(check_input))
|
723
726
|
rescue => e
|
724
727
|
err1 = "*** #{loc_str}: JSON isn't: #{JSON.dump(e.message[0..40])}\n"
|
725
728
|
begin
|
726
|
-
JSON.load("{" <<
|
729
|
+
JSON.load("{" << check_input << "}")
|
727
730
|
rescue => e
|
728
731
|
warn err1 << "*** not even with braces added around: #{JSON.dump(e.message[0..40])}"
|
729
732
|
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.6.
|
4
|
+
version: 1.6.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/kramdown-rfc/kdrfc-processor.rb
|
183
183
|
- lib/kramdown-rfc/parameterset.rb
|
184
184
|
- lib/kramdown-rfc/refxml.rb
|
185
|
+
- lib/kramdown-rfc/rexml-formatters-conservative.rb
|
185
186
|
- lib/kramdown-rfc/rfc8792.rb
|
186
187
|
- lib/kramdown-rfc/svg-id-cleanup.rb
|
187
188
|
- lib/kramdown-rfc2629.rb
|