kramdown-rfc2629 1.5.3 → 1.5.7
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/bin/de-gfm +40 -0
- data/bin/kramdown-rfc2629 +46 -2
- data/kramdown-rfc2629.gemspec +4 -3
- data/lib/kramdown-rfc/refxml.rb +4 -0
- data/lib/kramdown-rfc2629.rb +26 -5
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5fb1bbe625f32a0996caf7953ccdfb120dc675f98e3629ec4f0b1eb778952e2
|
4
|
+
data.tar.gz: 89b8e32c14263fb7ac0dc4ccd34f7cdbe9c0c264bce65e10f36c12fd9fda68a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff5b6843cfd27a6195c4a8a3a9735c8c180be6d376799d68c09ddbfcdd55919f33ed75ab6ae4e826252e2fdfc2b1c3c1ce91a548954ec9e8a4669e580c05ab6e
|
7
|
+
data.tar.gz: a7c3f4fe40f33059be269ffd6342b46e924b93751d43da1cb71ba356a1bec3e550a026bf2f6f6da0505813a0ab97ed845d40cad9cda411b2ff11cc95d138218d
|
data/bin/de-gfm
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby -Ku
|
2
|
+
|
3
|
+
Encoding.default_external = "UTF-8" # wake up, smell the coffee
|
4
|
+
|
5
|
+
require 'kramdown'
|
6
|
+
require 'kramdown-parser-gfm'
|
7
|
+
|
8
|
+
if ARGV[0] == '-k' # kramdown
|
9
|
+
MARKDOWN_BR = "\\\\\n"
|
10
|
+
ARGV.shift
|
11
|
+
end
|
12
|
+
|
13
|
+
if ARGV[0] == '-c' # commonmark
|
14
|
+
MARKDOWN_BR = "\\\n"
|
15
|
+
ARGV.shift
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV[0] == '-b' # universal HTML
|
19
|
+
MARKDOWN_BR = "<br/>\n"
|
20
|
+
ARGV.shift
|
21
|
+
end
|
22
|
+
|
23
|
+
MARKDOWN_BR ||= " \n" # original Gruber
|
24
|
+
|
25
|
+
module Kramdown
|
26
|
+
|
27
|
+
module Converter
|
28
|
+
|
29
|
+
# Converts an element tree to the kramdown format.
|
30
|
+
class Kramdown < Base
|
31
|
+
|
32
|
+
# Argh
|
33
|
+
def convert_br(_el, _opts)
|
34
|
+
MARKDOWN_BR
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
puts Kramdown::Document.new(ARGF.read, input: 'GFM', gfm_quirks: 'paragraph_end').to_kramdown
|
data/bin/kramdown-rfc2629
CHANGED
@@ -12,6 +12,24 @@ KDRFC_VERSION=Gem.loaded_specs["kramdown-rfc2629"].version rescue "unknown-versi
|
|
12
12
|
|
13
13
|
Encoding.default_external = "UTF-8" # wake up, smell the coffee
|
14
14
|
|
15
|
+
# Note that this doesn't attempt to handle HT characters
|
16
|
+
def remove_indentation(s)
|
17
|
+
l = s.lines
|
18
|
+
indent = l.grep(/\S/).map {|l| l[/^\s*/].size}.min
|
19
|
+
l.map {|li| li.sub(/^ {0,#{indent}}/, "")}.join
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_quote(s)
|
23
|
+
l = s.lines
|
24
|
+
l.map {|li| "> #{li}"}.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def process_chunk(s, dedent, quote)
|
28
|
+
s = remove_indentation(s) if dedent
|
29
|
+
s = add_quote(s) if quote
|
30
|
+
s
|
31
|
+
end
|
32
|
+
|
15
33
|
def boilerplate(key)
|
16
34
|
case key.downcase
|
17
35
|
when /\Abcp14(info)?(\+)?(-tagged)?\z/i
|
@@ -437,8 +455,34 @@ if input[-1] != "\n"
|
|
437
455
|
# warn "*** added missing newline at end"
|
438
456
|
input << "\n" # fix #26
|
439
457
|
end
|
440
|
-
input.gsub!(/^\{::include\s+(.*?)\}/) {
|
441
|
-
|
458
|
+
input.gsub!(/^\{::include((?:-[a-z]+)*)\s+(.*?)\}/) {
|
459
|
+
include_flags = $1
|
460
|
+
fn = [$2]
|
461
|
+
chunks = false
|
462
|
+
dedent = false
|
463
|
+
quote = false
|
464
|
+
include_flags.split("-") do |flag|
|
465
|
+
case flag
|
466
|
+
when ""
|
467
|
+
when "quote"
|
468
|
+
quote = true
|
469
|
+
when "dedent"
|
470
|
+
dedent = true
|
471
|
+
when "all", "last"
|
472
|
+
fn = fn.flat_map{|n| Dir[n]}
|
473
|
+
fn = [fn.last] if flag == "last"
|
474
|
+
chunks = fn.map{ |f|
|
475
|
+
ret = process_chunk(File.read(f), dedent, quote)
|
476
|
+
dedent = false; quote = false
|
477
|
+
ret
|
478
|
+
}
|
479
|
+
else
|
480
|
+
warn "** unknown include flag #{flag}"
|
481
|
+
end
|
482
|
+
end
|
483
|
+
chunks = fn.map{|f| File.read(f)} unless chunks # no all/last
|
484
|
+
chunks = chunks.map {|ch| process_chunk(ch, dedent, quote)}
|
485
|
+
chunks.join.chomp
|
442
486
|
} unless ENV["KRAMDOWN_SAFE"]
|
443
487
|
input.gsub!(/^\{::boilerplate\s+(.*?)\}/) {
|
444
488
|
boilerplate($1)
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.5.
|
3
|
+
s.version = '1.5.7'
|
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.}
|
7
7
|
s.add_dependency('kramdown', '~> 2.3.0')
|
8
|
+
s.add_dependency('kramdown-parser-gfm', '~> 1.1')
|
8
9
|
s.add_dependency('certified', '~> 1.0')
|
9
10
|
s.add_dependency('json_pure', '~> 2.0')
|
10
|
-
s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json)
|
11
|
+
s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/de-gfm)
|
11
12
|
s.require_path = 'lib'
|
12
13
|
s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
|
13
14
|
'kdrfc', 'kramdown-rfc-cache-i-d-bibxml',
|
14
|
-
'kramdown-rfc-cache-subseries-bibxml']
|
15
|
+
'kramdown-rfc-cache-subseries-bibxml', 'de-gfm']
|
15
16
|
s.required_ruby_version = '>= 2.3.0'
|
16
17
|
# s.requirements = 'wget'
|
17
18
|
# s.has_rdoc = true
|
data/lib/kramdown-rfc/refxml.rb
CHANGED
@@ -51,6 +51,10 @@ module KramdownRFC
|
|
51
51
|
# -- only works for people with exactly one last name and uncomplicated first names
|
52
52
|
if n = aups.rest["name"]
|
53
53
|
n = n.split
|
54
|
+
if s = aups.rest["surname"]
|
55
|
+
s = s.split
|
56
|
+
# XXX remove s from n; use n[0..-2] otherwise.
|
57
|
+
end
|
54
58
|
aups.rest["initials"] ||= n[0..-2].map(&:chr).join('.') << '.'
|
55
59
|
aups.rest["surname"] ||= n[-1]
|
56
60
|
end
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -54,7 +54,11 @@ module Kramdown
|
|
54
54
|
def self.idref_cleanup(href)
|
55
55
|
# can't start an IDREF with a number or reserved start
|
56
56
|
if href =~ / /
|
57
|
-
|
57
|
+
if $options.v3
|
58
|
+
warn "** space(s) in cross-reference '#{href}' -- are you trying to use section references?"
|
59
|
+
else
|
60
|
+
warn "** space(s) in cross-reference '#{href}' -- note that section references are supported in v3 mode only."
|
61
|
+
end
|
58
62
|
end
|
59
63
|
href.gsub(/\A(?:[0-9]|section-|u-|figure-|table-|iref-)/) { "_#{$&}" }
|
60
64
|
end
|
@@ -128,9 +132,14 @@ module Kramdown
|
|
128
132
|
when /\A(.*) \((#{SECTIONS_RE})\)\z/
|
129
133
|
href = $1
|
130
134
|
handle_bares($2, attr, "parens", href)
|
131
|
-
when
|
132
|
-
href = $
|
133
|
-
|
135
|
+
when /#{XREF_RE_M}<(.+)\z/
|
136
|
+
href = $3
|
137
|
+
if $2
|
138
|
+
attr['section'] = $2
|
139
|
+
attr['relative'] = "#" << $1
|
140
|
+
else
|
141
|
+
attr['section'] = $1
|
142
|
+
end
|
134
143
|
attr['sectionFormat'] = 'bare'
|
135
144
|
when /\A<<(.+)\z/
|
136
145
|
href = $1
|
@@ -374,8 +383,20 @@ COLORS
|
|
374
383
|
end
|
375
384
|
end
|
376
385
|
|
386
|
+
SVG_NAMESPACES = {"xmlns"=>"http://www.w3.org/2000/svg",
|
387
|
+
"xlink"=>"http://www.w3.org/1999/xlink"}
|
388
|
+
|
377
389
|
def svg_clean_kgt(s)
|
378
390
|
d = REXML::Document.new(s)
|
391
|
+
REXML::XPath.each(d.root, "/xmlns:svg", SVG_NAMESPACES) do |x|
|
392
|
+
if (w = x.attributes["width"]) && (h = x.attributes["height"])
|
393
|
+
x.attributes["viewBox"] = "0 0 %d %d" % [w, h]
|
394
|
+
end
|
395
|
+
if x.attributes["viewBox"]
|
396
|
+
x.attributes["width"] = nil
|
397
|
+
x.attributes["height"] = nil
|
398
|
+
end
|
399
|
+
end
|
379
400
|
REXML::XPath.each(d.root, "//rect|//line|//path") do |x|
|
380
401
|
x.attributes["fill"] = "none"
|
381
402
|
x.attributes["stroke"] = "black"
|
@@ -927,7 +948,7 @@ COLORS
|
|
927
948
|
],
|
928
949
|
"I-D" => ["bibxml3", false, false,
|
929
950
|
->(fn, n){ [fn,
|
930
|
-
"https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}
|
951
|
+
"https://datatracker.ietf.org/doc/bibxml3/draft-#{n.sub(/\Adraft-/, '')}.xml"] }
|
931
952
|
],
|
932
953
|
"BCP" => ["bibxml-rfcsubseries", 86400*7, false,
|
933
954
|
->(fn, n){ Rfc2629::bcp_std_ref("BCP", n) }
|
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.5.
|
4
|
+
version: 1.5.7
|
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-07
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kramdown-parser-gfm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: certified
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,11 +77,13 @@ executables:
|
|
63
77
|
- kdrfc
|
64
78
|
- kramdown-rfc-cache-i-d-bibxml
|
65
79
|
- kramdown-rfc-cache-subseries-bibxml
|
80
|
+
- de-gfm
|
66
81
|
extensions: []
|
67
82
|
extra_rdoc_files: []
|
68
83
|
files:
|
69
84
|
- LICENSE
|
70
85
|
- README.md
|
86
|
+
- bin/de-gfm
|
71
87
|
- bin/doilit
|
72
88
|
- bin/kdrfc
|
73
89
|
- bin/kramdown-rfc-cache-i-d-bibxml
|