kramdown-rfc2629 1.6.25 → 1.6.27

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: 3977e2f9efc48b95ff26f4559ac3442b2a66276d73def5ef190fac81e66c702b
4
- data.tar.gz: 3d5a0bbe14f3457763cd0172d6912b32ab6ccec70e3c8106a58173587fd57b61
3
+ metadata.gz: 7debb198a9e9bf5c199901337cdaa69059c72345a83c18092aaa24bbc1b533b7
4
+ data.tar.gz: c321ce924e845f46ded79a23b1ffbc8bee52e6fb6352ec49e332b94fd63e8b1e
5
5
  SHA512:
6
- metadata.gz: c085a74725465ff0cee2d1dc09af85e642b49528d45ba16be323b368c1e9106d27f2c7fbbe3ede62e5de284974d1740d273dec69e288058540bfd3d8bdffb536
7
- data.tar.gz: 19e8406e4c7accbd6c90308089a2dbb155167e2ed9cb7087c6b758c47ce097c902211d107eacff6dde08e429e2b4a3efba572327c2415c57f545a645edfe778a
6
+ metadata.gz: 36ea96fc6d606198c451fc2fab24cf50a8472a099380c5ff82b6326aa924e55b3a3e51b9180210dd4caf97e57a8aad0c6652e12c8cd05d814b32b5511f969e25
7
+ data.tar.gz: 025bc51c6061f60e258f512a0a5c10710da45083408a16135ffa6d4f234e412cabc8b17e8ce98bd913ccfb5c97869a02084400d9c9917df3e49b08c7a2016c6a
data/bin/echars CHANGED
@@ -1,17 +1,68 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'unicode/name'
3
- hist = Hash.new(0)
4
- ARGF.read.each_char do |c|
5
- hist[c] += 1 unless c.ord.between?(32, 126)
3
+ require 'unicode/scripts'
4
+ require 'unicode/blocks'
5
+ require 'json'
6
+ require 'differ'
7
+ module Differ
8
+ module Format
9
+ module Color
10
+ class << self
11
+ def as_change(change) # monkey patch
12
+ as_insert(change) << "\n" << as_delete(change)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+ def readable(c)
21
+ j = c.to_json
22
+ if j.size == 3
23
+ j[1...-1]
24
+ else
25
+ j
26
+ end
6
27
  end
7
- hist.delete("\n")
8
- cl = "*** Latin"
9
- hist.keys.sort.partition {|c| c =~ /\A\p{Latin}\z/}.each do |l|
10
- puts cl unless l.empty?
11
- l.each do |c|
12
- puts "#{c}: U+#{"%04X %4d" % [c.ord, hist[c]]
28
+
29
+ def explain(s)
30
+ ret = ''
31
+ hist = Hash.new(0)
32
+ s.each_char do |c|
33
+ hist[c] += 1 unless c.ord.between?(32, 126)
34
+ end
35
+ hist.delete("\n")
36
+ hist.keys.sort.group_by {|c| Unicode::Blocks.block(c)}.each do |block, l|
37
+ scripts = Set[]
38
+ l.each do |c|
39
+ scripts << Unicode::Scripts.scripts(c)
40
+ end
41
+ ret << "*** #{block}"
42
+ ret << " (#{scripts.join})" if scripts.size == 1
43
+ ret << "\n"
44
+ l.each do |c|
45
+ ret << "#{readable(c)}: U+#{"%04X %4d" % [c.ord, hist[c]]
13
46
  } #{Unicode::Name.correct(c) ||
14
- Unicode::Name.label(c)}"
47
+ Unicode::Name.label(c)
48
+ }"
49
+ ret << " (#{Unicode::Scripts.scripts(c).join(", ")})" if scripts.size != 1
50
+ ret << "\n"
51
+ end
15
52
  end
16
- cl = "*** Non-Latin"
53
+ ret
54
+ end
55
+
56
+ s = ARGF.read
57
+ es = explain(s)
58
+ n = s.unicode_normalize
59
+ en = explain(n)
60
+ if es == en
61
+ puts es
62
+ else
63
+ puts "*** Warning: some characters are not normalized and are shown in red."
64
+ puts " ...showing a normalized variant (NFC) in green."
65
+ puts " Lack of normalization may or may not be a problem."
66
+ puts " (Characters may appear to be under wrong block heading.)"
67
+ puts Differ.diff_by_line(en, es).format_as(:color)
17
68
  end
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.6.25'
3
+ s.version = '1.6.27'
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.}
@@ -9,7 +9,10 @@ spec = Gem::Specification.new do |s|
9
9
  s.add_dependency('certified', '~> 1.0')
10
10
  s.add_dependency('json_pure', '~> 2.0')
11
11
  s.add_dependency('unicode-name', '~> 1.0')
12
+ s.add_dependency('unicode-blocks', '~> 1.0')
13
+ s.add_dependency('unicode-scripts', '~> 1.0')
12
14
  s.add_dependency('net-http-persistent', '~> 4.0')
15
+ s.add_dependency('differ', '~>0.1')
13
16
  s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc bin/kramdown-rfc2629 bin/doilit bin/echars bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json bin/kramdown-rfc-cache-subseries-bibxml bin/kramdown-rfc-autolink-iref-cleanup bin/de-gfm)
14
17
  s.require_path = 'lib'
15
18
  s.executables = ['kramdown-rfc', 'kramdown-rfc2629', 'doilit', 'echars',
@@ -37,12 +37,63 @@ def process_mkd(input, output)
37
37
  end
38
38
  end
39
39
 
40
- def run_idnits(txt_fn)
40
+ def run_idnits(*args)
41
+ if @options.remote
42
+ run_idnits_remotely(*args)
43
+ else
44
+ run_idnits_locally(*args)
45
+ end
46
+ end
47
+
48
+ def run_idnits_locally(txt_fn)
49
+ warn "* running idnits locally in txt #{txt_fn}" if @options.verbose
41
50
  unless system("idnits", txt_fn)
42
- warn "*** problem #$? running idnits"
51
+ warn "*** problem #$? running idnits" if @options.verbose
52
+ warn "*** problem running idnits -- falling back to remote idnits processing"
53
+ run_idnits_remotely(txt_fn)
43
54
  end
44
55
  end
45
56
 
57
+ # curl -s https://author-tools.ietf.org/api/idnits -X POST -F file=@draft-ietf-core-comi.txt -F hidetext=true
58
+ IDNITS_WEBSERVICE = ENV["KRAMDOWN_IDNITS_WEBSERVICE"] ||
59
+ 'https://author-tools.ietf.org/api/idnits'
60
+
61
+ def run_idnits_remotely(txt_fn)
62
+ url = URI(IDNITS_WEBSERVICE)
63
+ req = Net::HTTP::Post.new(url)
64
+ form = [["file", File.open(txt_fn),
65
+ {filename: "input.txt",
66
+ content_type: "text/plain"}],
67
+ ["hidetext", "true"]]
68
+ diag = ["url/form: ", url, form].inspect
69
+ req.set_form(form, 'multipart/form-data')
70
+ warn "* requesting idnits at #{url}" if @options.verbose
71
+ t0 = Time.now
72
+ res = persistent_http.request(url, req)
73
+ warn "* elapsed time: #{Time.now - t0}" if @options.verbose
74
+ case res
75
+ when Net::HTTPBadRequest
76
+ result = checked_json(res.body)
77
+ raise IOError.new("*** Remote Error: #{result["error"]}")
78
+ when Net::HTTPOK
79
+ case res.content_type
80
+ when 'text/plain'
81
+ if res.body == ''
82
+ raise IOError.new("*** HTTP response is empty with status #{res.code}, not written")
83
+ end
84
+ puts res.body
85
+ else
86
+ warning = "*** HTTP response has unexpected content_type #{res.content_type} with status #{res.code}, #{diag}"
87
+ warning << "\n"
88
+ warning << res.body
89
+ raise IOError.new(warning)
90
+ end
91
+ else
92
+ raise IOError.new("*** HTTP response: #{res.code}, #{diag}")
93
+ end
94
+ end
95
+
96
+
46
97
  def process_xml(*args)
47
98
  if @options.remote
48
99
  process_xml_remotely(*args)
@@ -175,6 +226,8 @@ def process(fn)
175
226
  xml = "#$1.xml"
176
227
  process_mkd(fn, xml)
177
228
  process_the_xml(xml, $1) unless @options.xml_only
229
+ when /(.*)\.txt\z/
230
+ run_idnits(fn) if @options.idnits
178
231
  else
179
232
  raise ArgumentError.new("Unknown file type: #{fn}")
180
233
  end
@@ -260,6 +260,9 @@ module Kramdown
260
260
  if anchor = a.delete('href')
261
261
  a['target'] = ::Kramdown::Parser::RFC2629Kramdown.idref_cleanup(anchor)
262
262
  end
263
+ if lang = a.delete('lang-')
264
+ a['xml:lang'] = lang
265
+ end
263
266
  if av = a.delete('noabbrev') # pseudo attribute -> opts
264
267
  opts = opts.merge(noabbrev: TRUTHY[av]) # updated copy
265
268
  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.25
4
+ version: 1.6.27
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-02-27 00:00:00.000000000 Z
11
+ date: 2023-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: unicode-blocks
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: unicode-scripts
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: net-http-persistent
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +122,20 @@ dependencies:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
124
  version: '4.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: differ
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.1'
97
139
  description: |-
98
140
  An RFCXML (RFC 799x) generating backend for Thomas Leitner's
99
141
  "kramdown" markdown parser. Mostly useful for RFC writers.
@@ -157,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
199
  - !ruby/object:Gem::Version
158
200
  version: '0'
159
201
  requirements: []
160
- rubygems_version: 3.4.2
202
+ rubygems_version: 3.4.6
161
203
  signing_key:
162
204
  specification_version: 4
163
205
  summary: Kramdown extension for generating RFCXML (RFC 799x).