kramdown-rfc2629 1.0.30 → 1.0.31

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
  SHA1:
3
- metadata.gz: a7bc8abb77836597a85d3759acc1b9c967ab08b9
4
- data.tar.gz: 0f0936ec35dcaa2f17fcad200b8078a5280d4f6d
3
+ metadata.gz: fcc80ff8452a6c29a365f184426a4a9d2d346e92
4
+ data.tar.gz: ffc0f0ba4f64bd1e51c33f5c8b1756c6dada5277
5
5
  SHA512:
6
- metadata.gz: d4ff0aa08e50fa874c90c83eaaacc8239ee3d313f1862d6f0f40d4aced3761bc727e52f4f2fc48aab71354a5b0d1fa377d4f5ac4266c4036f2325d707988d788
7
- data.tar.gz: 76ca0282a1f3aa15ab0b72c61bd17b1865ec703cc54820e1926dc1d8c1516c59d9103ffccb2bfd099ba68a2a759f607c1fe6cd9d13d8867dfbf0f54bc35822f2
6
+ metadata.gz: 58829e34c29a6834597576892379a486996833fda2ca5ed61be70aa1adf9e1acc924a2fba4de4f76ec282a55d3997581def245c005dbf1e3f763d3b23a92258b
7
+ data.tar.gz: d59d551ce80cc1b38a14ff13064cf25a751b01e2a96de052341d3ec2c7e5e68a1f21d4278533e7e2e0a494013c86b247abeef91ef978177febef525a2f68cda0
data/README.md CHANGED
@@ -234,6 +234,22 @@ special support in XML2RFC), and HTML syntax of course.
234
234
  A number of more esoteric features have recently been added.
235
235
  (The minimum required version for each full feature is indicated.)
236
236
 
237
+ (1.0.31:)
238
+ The kramdown `smart_quotes` feature can be controlled better.
239
+ By default, it is on (with default kramdown settings), unless `coding:
240
+ us-ascii` is in effect, when it is off by default.
241
+ It also can be explicitly set on (`true`) or off (`false`) in the YAML
242
+ header, or to a specific value (an array of four kramdown entity names
243
+ or character numbers). E.g., for a German text (that is not intended
244
+ to become an Internet-Draft), one might write:
245
+
246
+ ```yaml
247
+ smart_quotes: [sbquo, lsquo, bdquo, ldquo]
248
+ pi:
249
+ topblock: no
250
+ private: yes
251
+ ```
252
+
237
253
  (1.0.30:)
238
254
  kramdown-rfc now uses kramdown 1.10, which leads to two notable updates:
239
255
 
data/bin/kramdown-rfc2629 CHANGED
@@ -22,7 +22,8 @@ def xml_from_sections(input)
22
22
  # We put back the "---" plus gratuitous blank lines to hack the line number in errors
23
23
  yaml_in = input[/---\s*/] << sections.shift[2]
24
24
  ps = ParameterSet.new(YAML.load(yaml_in))
25
- coding_override = (ps.has(:coding) =~ /ascii/i) ? :symbolic : :as_char
25
+ coding_override = ps.has(:coding)
26
+ smart_quotes = ps[:smart_quotes]
26
27
 
27
28
  # all the other sections are put in a Hash, possibly concatenated from parts there
28
29
  sechash = Hash.new{ |h,k| h[k] = ""}
@@ -173,7 +174,7 @@ def xml_from_sections(input)
173
174
  warn "*** sections left #{sechash.keys.inspect}!"
174
175
  end
175
176
 
176
- [input, coding_override, link_defs]
177
+ [input, coding_override, link_defs, smart_quotes]
177
178
  end
178
179
 
179
180
  class ParameterSet
@@ -277,6 +278,23 @@ def dateattrs(date)
277
278
  end
278
279
  end
279
280
 
281
+ def read_encodings
282
+ encfilename = File.expand_path '../../data/encoding-fallbacks.txt', __FILE__
283
+ encfile = File.read(encfilename, coding: "UTF-8")
284
+ Hash[encfile.lines.map{|l|
285
+ l.chomp!;
286
+ x, s = l.split(" ", 2)
287
+ [x.hex.chr(Encoding::UTF_8), s || " "]}]
288
+ end
289
+
290
+ FALLBACK = read_encodings
291
+
292
+ def expand_tabs(s, tab_stops = 8)
293
+ s.gsub(/([^\t\n]*)\t/) do
294
+ $1 + " " * (tab_stops - ($1.size % tab_stops))
295
+ end
296
+ end
297
+
280
298
  coding_override = :as_char
281
299
  input = ARGF.read
282
300
  if input[0] == "\uFEFF"
@@ -286,18 +304,37 @@ end
286
304
  input.gsub!(/^\{::include\s+(.*?)\}/) {
287
305
  File.read($1).chomp
288
306
  } unless ENV["KRAMDOWN_SAFE"]
307
+ if input =~ /[\t]/
308
+ warn "*** Input contains HT (\"tab\") characters. Undefined behavior will ensue."
309
+ input = expand_tabs(input)
310
+ end
289
311
  link_defs = {}
290
312
  if input =~ /\A---/ # this is a sectionized file
291
- input, coding_override, link_defs = xml_from_sections(input)
313
+ input, target_coding, link_defs, smart_quotes = xml_from_sections(input)
292
314
  end
293
315
  if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
294
316
  input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
295
317
  end
296
318
  options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
297
- case coding_override
298
- when :symbolic
299
- options[:smart_quotes] = ["'".ord, "'".ord, '"'.ord, '"'.ord]
319
+ if target_coding && target_coding =~ /ascii/ && smart_quotes.nil?
320
+ smart_quotes = false
321
+ end
322
+ if smart_quotes == false
323
+ smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
324
+ end
325
+ case smart_quotes
326
+ when Array
327
+ options[:smart_quotes] = smart_quotes
328
+ when nil, true
329
+ # nothin
330
+ else
331
+ warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
300
332
  end
333
+
334
+ if target_coding
335
+ input = input.encode(Encoding.find(target_coding), fallback: FALLBACK)
336
+ end
337
+
301
338
  # warn "options: #{options.inspect}"
302
339
  doc = Kramdown::Document.new(input, options)
303
340
  $stderr.puts doc.warnings.to_yaml unless doc.warnings.empty?
@@ -0,0 +1,161 @@
1
+ 00a1 !
2
+ 00a2 [cents]
3
+ 00a3 GBP
4
+ 00a4 [currency units]
5
+ 00a5 JPY
6
+ 00a6 |
7
+ 00a7 S.
8
+ 00a9 (C)
9
+ 00aa a
10
+ 00ab <<
11
+ 00ac [not]
12
+ 00ae (R)
13
+ 00af _
14
+ 00b0 o
15
+ 00b1 +/-
16
+ 00b2 ^2
17
+ 00b3 ^3
18
+ 00b4 '
19
+ 00b5 [micro]
20
+ 00b6 P.
21
+ 00b7 .
22
+ 00b8 ,
23
+ 00b9 ^1
24
+ 00ba o
25
+ 00bb >>
26
+ 00bc 1/4
27
+ 00bd 1/2
28
+ 00be 3/4
29
+ 00bf ?
30
+ 00c0 A
31
+ 00c1 A
32
+ 00c2 A
33
+ 00c3 A
34
+ 00c4 Ae
35
+ 00c5 Ae
36
+ 00c6 AE
37
+ 00c7 C
38
+ 00c8 E
39
+ 00c9 E
40
+ 00ca E
41
+ 00cb E
42
+ 00cc I
43
+ 00cd I
44
+ 00ce I
45
+ 00cf I
46
+ 00d0 [ETH]
47
+ 00d1 N
48
+ 00d2 O
49
+ 00d3 O
50
+ 00d4 O
51
+ 00d5 O
52
+ 00d6 Oe
53
+ 00d7 x
54
+ 00d8 Oe
55
+ 00d9 U
56
+ 00da U
57
+ 00db U
58
+ 00dc Ue
59
+ 00dd Y
60
+ 00de [THORN]
61
+ 00df ss
62
+ 00e0 a
63
+ 00e1 a
64
+ 00e2 a
65
+ 00e3 a
66
+ 00e4 ae
67
+ 00e5 ae
68
+ 00e6 ae
69
+ 00e7 c
70
+ 00e8 e
71
+ 00e9 e
72
+ 00ea e
73
+ 00eb e
74
+ 00ec i
75
+ 00ed i
76
+ 00ee i
77
+ 00ef i
78
+ 00f0 [eth]
79
+ 00f1 n
80
+ 00f2 o
81
+ 00f3 o
82
+ 00f4 o
83
+ 00f5 o
84
+ 00f6 oe
85
+ 00f7 /
86
+ 00f8 oe
87
+ 00f9 u
88
+ 00fa u
89
+ 00fb u
90
+ 00fc ue
91
+ 00fd y
92
+ 00fe [thorn]
93
+ 00ff y
94
+ 0152 OE
95
+ 0153 oe
96
+ 0161 s
97
+ 0178 Y
98
+ 0192 f
99
+ 02dc ~
100
+ 2002
101
+ 2003
102
+ 2009
103
+ 2013 --
104
+ 2014 ---
105
+ 2018 '
106
+ 2019 '
107
+ 201a '
108
+ 201c "
109
+ 201d "
110
+ 201e "
111
+ 2020 *!*
112
+ 2021 *!!*
113
+ 2022 o
114
+ 2026 ...
115
+ 2030 [/1000]
116
+ 2032 '
117
+ 2039 <
118
+ 203a >
119
+ 2044 /
120
+ 20ac EUR
121
+ 2122 [TM]
122
+ 2190 <--
123
+ 2192 -->
124
+ 2194 <->
125
+ 21d0 <==
126
+ 21d2 ==>
127
+ 21d4 <=>
128
+ 2212 -
129
+ 2217 *
130
+ 2264 <=
131
+ 2265 >=
132
+ 2329 <
133
+ 232a >
134
+ 0021 !
135
+ 0023 #
136
+ 0024 $
137
+ 0025 %
138
+ 0028 (
139
+ 0029 )
140
+ 002a *
141
+ 002b +
142
+ 002c ,
143
+ 002d -
144
+ 002e .
145
+ 002f /
146
+ 003a :
147
+ 003b ;
148
+ 003d =
149
+ 003f ?
150
+ 0040 @
151
+ 005b [
152
+ 005d ]
153
+ 005e ^
154
+ 005f _
155
+ 0060 `
156
+ 007b {
157
+ 007c |
158
+ 007d }
159
+ 017d Z
160
+ 017e z
161
+ 2010 -
@@ -1,11 +1,11 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.0.30'
3
+ s.version = '1.0.31'
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.10.0')
8
- s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kramdown-rfc2629 data/kramdown-rfc2629.erb)
7
+ s.add_dependency('kramdown', '~> 1.11.0')
8
+ s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kramdown-rfc2629 data/kramdown-rfc2629.erb data/encoding-fallbacks.txt)
9
9
  s.require_path = 'lib'
10
10
  s.executables = ['kramdown-rfc2629']
11
11
  s.default_executable = 'kramdown-rfc2629'
@@ -11,7 +11,7 @@
11
11
 
12
12
  raise "sorry, 1.8 was last decade" unless RUBY_VERSION >= '1.9'
13
13
 
14
- gem 'kramdown', '~> 1.10.0'
14
+ gem 'kramdown', '~> 1.11.0'
15
15
  require 'kramdown'
16
16
  my_span_elements = %w{list figure xref eref iref cref spanx vspace}
17
17
  Kramdown::Parser::Html::Constants::HTML_SPAN_ELEMENTS.concat my_span_elements
@@ -549,7 +549,7 @@ module Kramdown
549
549
  end
550
550
 
551
551
  def convert_smart_quote(el, indent, opts)
552
- entity_to_str(::Kramdown::Utils::Entities.entity(el.value.to_s))
552
+ entity_to_str(smart_quote_entity(el))
553
553
  end
554
554
 
555
555
  def convert_math(el, indent, opts) # XXX: This is wrong
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.0.30
4
+ version: 1.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-06-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.10.0
19
+ version: 1.11.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.10.0
26
+ version: 1.11.0
27
27
  description: |-
28
28
  An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
29
29
  "kramdown" markdown parser. Mostly useful for RFC writers.
@@ -36,6 +36,7 @@ files:
36
36
  - LICENSE
37
37
  - README.md
38
38
  - bin/kramdown-rfc2629
39
+ - data/encoding-fallbacks.txt
39
40
  - data/kramdown-rfc2629.erb
40
41
  - kramdown-rfc2629.gemspec
41
42
  - lib/kramdown-rfc2629.rb
@@ -59,9 +60,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
60
  version: '0'
60
61
  requirements: []
61
62
  rubyforge_project:
62
- rubygems_version: 2.4.8
63
+ rubygems_version: 2.5.1
63
64
  signing_key:
64
65
  specification_version: 4
65
66
  summary: Kramdown extension for generating RFC 7749 XML.
66
67
  test_files: []
67
- has_rdoc: