kramdown-rfc2629 1.3.33 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b532912e56847cec71ed5c419ea08af4d19d3f6c7a4d91edffbfaa3005dd37f
4
- data.tar.gz: 6dbf519c9eadbddb50a07f6b1cef88cdcc9d877a5f66614ececf6bf5bc2d3353
3
+ metadata.gz: e810a295696230d06daa18981cff3c92ad0913175b717027788ee41351d4df6f
4
+ data.tar.gz: 5d5db17408cc47211883b0d95071139d47fb7fd8d8391cb9eff59217e81c330d
5
5
  SHA512:
6
- metadata.gz: 0f7f9faf79c570a7bcca633aef94a6f27d997d861eca1ecad0855795eef44728d925cc1d1b7751454b6c122168d12ef4f341b4ed350d8aeb9247b53e13d523ba
7
- data.tar.gz: 2dcdb7cf588bd99e8e983b71eefbbb0a2aec8785f466abe8e83f6b7ea40061aecea69abe6466d94d2dc69c019dd798a0569e5ed66b65efc42bf76d448ef45778
6
+ metadata.gz: 30d01f719beb7b67932396d4e28f6e1c4f9446029e04555706089e33615c305a673443922927136dad47f974c5c45cd871655a778c97347fa40a6f5454df7970
7
+ data.tar.gz: ef7be0d8a0b914f67a871e813533ad5eee7280bb31d67047d688ddf164ce124763653980b6c097f4be596be4211d32062efae15e5726d90618aca709cc63a462
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+ # prerequisite:
3
+ # gem install net-http-persistent
4
+ #
5
+ # dumps all bibxml for current, "Active" I-Ds in cache
6
+ # reasonably efficient after initial call if the output is retained
7
+ #
8
+ # requires Ruby 2.4 or above because of "liberal_parsing" option
9
+ #
10
+ # uses ENV["KRAMDOWN_REFCACHEDIR"] for where you want to have your bibxml3 data
11
+ #
12
+
13
+ require 'csv'
14
+ require 'fileutils'
15
+
16
+ begin
17
+ require 'net/http/persistent'
18
+ rescue
19
+ warn "*** please install net-http-persistent:"
20
+ warn " gem install net-http-persistent"
21
+ warn "(prefix by sudo only if required)."
22
+ exit 72 # EX_OSFILE
23
+ end
24
+
25
+
26
+ TARGET_DIR = ENV["KRAMDOWN_REFCACHEDIR"] || (
27
+ path = File.expand_path("~/.cache/xml2rfc")
28
+ warn "*** set environment variable KRAMDOWN_REFCACHEDIR to #{path} to actually use the cache"
29
+ path
30
+ )
31
+
32
+ FileUtils.mkdir_p(TARGET_DIR)
33
+ FileUtils.chdir(TARGET_DIR)
34
+
35
+ $http = Net::HTTP::Persistent.new name: 'allid'
36
+
37
+ KRAMDOWN_PERSISTENT_VERBOSE = true
38
+
39
+ def get_and_write_resource_persistently(url, fn, age_verbose=false)
40
+ t1 = Time.now
41
+ response = $http.request(URI(url))
42
+ if response.code != "200"
43
+ raise "*** Status code #{response.code} while fetching #{url}"
44
+ else
45
+ File.write(fn, response.body)
46
+ end
47
+ t2 = Time.now
48
+ warn "#{url} -> #{fn} (#{"%.3f" % (t2 - t1)} s)" if KRAMDOWN_PERSISTENT_VERBOSE
49
+ if age_verbose
50
+ if age = response.get_fields("age")
51
+ warn "(working from a web cache, index is #{age.first} seconds stale)"
52
+ end
53
+ end
54
+ end
55
+
56
+ CLEAR_RET = "\e[K\r" # XXX all the world is ECMA-48 (ISO 6429), no?
57
+
58
+ def noisy(name)
59
+ print "#{name}...#{CLEAR_RET}"
60
+ end
61
+ def clear_noise
62
+ print CLEAR_RET
63
+ end
64
+
65
+ ALL_ID2_SOURCE = "https://www.ietf.org/id/all_id2.txt"
66
+ ALL_ID2_COPY = ".all_id2.txt"
67
+
68
+ get_and_write_resource_persistently(ALL_ID2_SOURCE, ALL_ID2_COPY, true) unless ENV["KRAMDOWN_DONT_REFRESH_ALL_ID2"]
69
+ ix = File.read(ALL_ID2_COPY).lines.grep_v(/^#/).join
70
+
71
+ csv = CSV.new(ix, col_sep: "\t", liberal_parsing: true)
72
+
73
+ drafts = csv.read
74
+ active = drafts.select { |d| d[2] == "Active" }
75
+ active_names = active.map { |a| a[0] }
76
+ puts "#{active_names.size} active drafts"
77
+
78
+ active_names.each do |name|
79
+ if name =~ /\Adraft-(.*)-(\d\d)\z/
80
+ namepart = $1
81
+ version = $2
82
+ name0 = "reference.I-D.#{namepart}.xml"
83
+ noisy(name0) if File.exists?(name0)
84
+ name1 = "reference.I-D.draft-#{namepart}-#{version}.xml"
85
+ if File.exists?(name1)
86
+ noisy(name1)
87
+ FileUtils.touch(name0) # because name1 already exists, we believe name0 is fresh
88
+ else
89
+ begin
90
+ url0 = "https://datatracker.ietf.org/doc/bibxml3/draft-#{namepart}/xml"
91
+ get_and_write_resource_persistently(url0, name0) # get name0 first
92
+ url1 = "https://datatracker.ietf.org/doc/bibxml3/draft-#{namepart}-#{version}/xml"
93
+ get_and_write_resource_persistently(url1, name1) # then name1 to mark this as updated
94
+ rescue => e
95
+ warn "*** #{name0}: #{e}"
96
+ end
97
+ end
98
+ else
99
+ warn "*** Malformed draft name: #{name}"
100
+ end
101
+ end
102
+ clear_noise
@@ -108,6 +108,13 @@
108
108
  aups = KramdownRFC::authorps_from_hash(au)
109
109
  -%>
110
110
  <%= KramdownRFC::person_element_from_aups("contact", aups) -%>
111
+ <%= if contrib = aups["contribution"]
112
+ <<CONTRIBUTION
113
+ {:/nomarkdown}
114
+ #{contrib}
115
+ {::nomarkdown}
116
+ CONTRIBUTION
117
+ end -%>
111
118
  <% aups.warn_if_leftovers -%>
112
119
  <% end -%>
113
120
  <% end -%>
@@ -1,15 +1,16 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.33'
3
+ s.version = '1.4.1'
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
- s.add_dependency('kramdown', '~> 1.17.0')
7
+ s.add_dependency('kramdown', '~> 2.3.0')
8
8
  s.add_dependency('certified', '~> 1.0')
9
9
  s.add_dependency('json_pure', '~> 2.0')
10
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
11
  s.require_path = 'lib'
12
- s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown', 'kdrfc']
12
+ s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown',
13
+ 'kdrfc', 'kramdown-rfc-cache-i-d-bibxml']
13
14
  s.required_ruby_version = '>= 2.3.0'
14
15
  # s.requirements = 'wget'
15
16
  # s.has_rdoc = true
@@ -12,7 +12,7 @@ require 'shellwords'
12
12
 
13
13
  raise "sorry, 1.8 was last decade" unless RUBY_VERSION >= '1.9'
14
14
 
15
- gem 'kramdown', '~> 1.17.0'
15
+ gem 'kramdown', '~> 2.3.0'
16
16
  require 'kramdown'
17
17
  my_span_elements = %w{list figure xref eref iref cref spanx vspace}
18
18
  Kramdown::Parser::Html::Constants::HTML_SPAN_ELEMENTS.concat my_span_elements
@@ -38,6 +38,8 @@ module Kramdown
38
38
  super
39
39
  @span_parsers.unshift(:xref)
40
40
  @span_parsers.unshift(:iref)
41
+ @span_parsers.unshift(:span_pi)
42
+ @block_parsers.unshift(:block_pi)
41
43
  end
42
44
 
43
45
  SECTIONS_RE = /Section(?:s (?:[\w.]+, )*[\w.]+,? and)? [\w.]+/
@@ -112,7 +114,7 @@ module Kramdown
112
114
  end
113
115
  @tree.children << el
114
116
  end
115
- define_parser(:xref, XREF_START, '{{')
117
+ define_parser(:xref, XREF_START, '\{\{')
116
118
 
117
119
  IREF_START = /\(\(\((.*?)\)\)\)/u
118
120
 
@@ -125,6 +127,40 @@ module Kramdown
125
127
  end
126
128
  define_parser(:iref, IREF_START, '\(\(\(')
127
129
 
130
+ # HTML_INSTRUCTION_RE = /<\?(.*?)\?>/m # still defined!
131
+
132
+ # warn [:OPT_SPACE, OPT_SPACE, HTML_INSTRUCTION_RE].inspect
133
+
134
+ PI_BLOCK_START = /^#{OPT_SPACE}<\?/u
135
+
136
+ def parse_block_pi
137
+ # warn [:BLOCK].inspect
138
+ line = @src.current_line_number
139
+ if (result = @src.scan(HTML_INSTRUCTION_RE))
140
+ @tree.children << Element.new(:xml_pi, result, nil, category: :block, location: line)
141
+ @src.scan(TRAILING_WHITESPACE)
142
+ true
143
+ else
144
+ false
145
+ end
146
+ end
147
+ define_parser(:block_pi, PI_BLOCK_START)
148
+
149
+ PI_SPAN_START = /<\?/u
150
+
151
+ def parse_span_pi
152
+ # warn [:SPAN].inspect
153
+ line = @src.current_line_number
154
+ if (result = @src.scan(HTML_INSTRUCTION_RE))
155
+ @tree.children << Element.new(:xml_pi, result, nil, category: :span, location: line)
156
+ else
157
+ add_text(@src.getch)
158
+ end
159
+ end
160
+ define_parser(:span_pi, PI_SPAN_START, '<\?')
161
+
162
+ # warn [:HERE, @@parsers.keys].inspect
163
+
128
164
  end
129
165
  end
130
166
 
@@ -373,9 +409,12 @@ COLORS
373
409
  [result, result1] # text, svg
374
410
  end
375
411
 
412
+ ARTWORK_TYPES = %w(ascii-art binary-art call-flow hex-dump svg)
413
+
376
414
  def convert_codeblock(el, indent, opts)
377
415
  # el.attr['anchor'] ||= saner_generate_id(el.value) -- no longer in 1.0.6
378
416
  result = el.value
417
+ gi = el.attr.delete('gi')
379
418
  blockclass = el.attr.delete('class')
380
419
  if blockclass == 'language-tbreak'
381
420
  result = result.lines.map {|line| [line.chomp, 0]}
@@ -402,7 +441,7 @@ COLORS
402
441
  if md = cl.match(/\Alanguage-(.*)/)
403
442
  t = artwork_attr["type"] = md[1] # XXX overwrite
404
443
  else
405
- $stderr.puts "*** Unimplemented block class: #{cl}"
444
+ $stderr.puts "*** Unimplemented codeblock class: #{cl}"
406
445
  end
407
446
  end
408
447
  end
@@ -411,17 +450,27 @@ COLORS
411
450
  result[0,0] = "\n" unless result[0,1] == "\n"
412
451
  end
413
452
  el.attr.each do |k, v|
414
- if md = k.match(/\Aartwork-(.*)/)
453
+ if md = k.match(/\A(?:artwork|sourcecode)-(.*)/)
415
454
  el.attr.delete(k)
416
455
  artwork_attr[md[1]] = v
417
456
  end
418
457
  end
419
458
  case t
420
459
  when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", "mermaid", "math"
460
+ if gi
461
+ warn "*** Can't set GI #{gi} for composite SVG artset"
462
+ end
421
463
  result, result1 = memoize(:svg_tool_process, t, result)
422
464
  "#{' '*indent}<figure#{el_html_attributes(el)}><artset><artwork #{html_attributes(artwork_attr.merge("type"=> "svg"))}>#{result1.sub(/.*?<svg/m, "<svg")}</artwork><artwork #{html_attributes(artwork_attr.merge("type"=> "ascii-art"))}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></artset></figure>\n"
423
465
  else
424
- "#{' '*indent}<figure#{el_html_attributes(el)}><artwork#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></figure>\n"
466
+ gi ||= (
467
+ if !$options.v3 || !t || ARTWORK_TYPES.include?(t) || artwork_attr["align"]
468
+ "artwork"
469
+ else
470
+ "sourcecode"
471
+ end
472
+ )
473
+ "#{' '*indent}<figure#{el_html_attributes(el)}><#{gi}#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></#{gi}></figure>\n"
425
474
  end
426
475
  end
427
476
  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.33
4
+ version: 1.4.1
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-02-17 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.17.0
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.17.0
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: certified
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +61,7 @@ executables:
61
61
  - doilit
62
62
  - kramdown-rfc-extract-markdown
63
63
  - kdrfc
64
+ - kramdown-rfc-cache-i-d-bibxml
64
65
  extensions: []
65
66
  extra_rdoc_files: []
66
67
  files:
@@ -68,6 +69,7 @@ files:
68
69
  - README.md
69
70
  - bin/doilit
70
71
  - bin/kdrfc
72
+ - bin/kramdown-rfc-cache-i-d-bibxml
71
73
  - bin/kramdown-rfc-extract-markdown
72
74
  - bin/kramdown-rfc2629
73
75
  - data/encoding-fallbacks.txt