kramdown-rfc2629 1.3.11 → 1.3.16

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: 27d6f89b52a66240293897ef2d230d4ad4c7ea6e31bc5c4bc92594954d95ff18
4
- data.tar.gz: a4190f696dae283a37c5d17f2f104acee9e9d3a210090788d7c864d7886801a9
3
+ metadata.gz: 1aa033b3aa4b1de04e812815fc9eff8d4aefd79ead0eaa5b72c0df9addb83f2d
4
+ data.tar.gz: c95278268d3ff938b1b05283c1c865385424955999584c3170c9d5e06a1e23dc
5
5
  SHA512:
6
- metadata.gz: 1d2496cf171bbe05840bb63a80b6c92344743a19b7dbfd222d6ba0da88d9c965a459a1490be5cf2227e1875b09aa4fac009116ab472eb086cb2df70f3370f512
7
- data.tar.gz: 572be121dfa90210fbfb62df426ee81a3915988e7e81a83e102f4d106efc2626fd8d6012e9cec33f1c86d0aec7dd3d0524496d1e9dcbcb1a80043003b10ac923
6
+ metadata.gz: 994a974bd54cc86f4eb634c6fc7ca7ce0e3ccda4cc13d8e9abbafa4276202e22d5ed7a0587757208e5a35ca7c800b813a42c94781165d784a09e1b08c1be4135
7
+ data.tar.gz: 9a5bad18a176d28fcefcbfaedffca444b354345c67c88efce1bda45c98784208bf6a34e8d79df572b5992f574feecd122704bf188f24a4f532bff315a1e4084e
data/README.md CHANGED
@@ -351,7 +351,7 @@ generate XML2RFCv2 XML instead of kramdown-rfc YAML.
351
351
  (1.0.31:)
352
352
  The kramdown `smart_quotes` feature can be controlled better.
353
353
  By default, it is on (with default kramdown settings), unless `coding:
354
- us-ascii` is in effect, when it is off by default.
354
+ us-ascii` is in effect (1.3.14: or --v3 is given), in which case it is off by default.
355
355
  It also can be explicitly set on (`true`) or off (`false`) in the YAML
356
356
  header, or to a specific value (an array of four kramdown entity names
357
357
  or character numbers). E.g., for a German text (that is not intended
data/bin/kdrfc CHANGED
@@ -72,6 +72,10 @@ def process_xml_remotely(input, output)
72
72
  when Net::HTTPOK
73
73
  case res.content_type
74
74
  when 'application/octet-stream'
75
+ if res.body == ''
76
+ warn "*** HTTP response is empty with status #{res.code}, not written"
77
+ exit 1
78
+ end
75
79
  File.open(output, "w") do |fo|
76
80
  fo.print(res.body)
77
81
  end
@@ -87,6 +87,7 @@ def xml_from_sections(input)
87
87
  ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
88
88
  coding_override = ps.has(:coding)
89
89
  smart_quotes = ps[:smart_quotes]
90
+ typographic_symbols = ps[:typographic_symbols]
90
91
  kramdown_options = ps[:kramdown_options]
91
92
 
92
93
  # all the other sections are put in a Hash, possibly concatenated from parts there
@@ -237,7 +238,7 @@ def xml_from_sections(input)
237
238
  warn "*** sections left #{sechash.keys.inspect}!"
238
239
  end
239
240
 
240
- [input, coding_override, link_defs, smart_quotes, kramdown_options]
241
+ [input, coding_override, link_defs, smart_quotes, typographic_symbols, kramdown_options]
241
242
  end
242
243
 
243
244
  XML_RESOURCE_ORG_PREFIX = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_PREFIX
@@ -339,14 +340,16 @@ end
339
340
  link_defs = {}
340
341
  if input =~ /\A---/ # this is a sectionized file
341
342
  do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
342
- input, target_coding, link_defs, smart_quotes, kramdown_options = xml_from_sections(input)
343
+ input, target_coding, link_defs, smart_quotes, typographic_symbols, kramdown_options = xml_from_sections(input)
343
344
  end
344
345
  if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
345
346
  input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
346
347
  end
347
348
  options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
348
- if target_coding && target_coding =~ /ascii/ && smart_quotes.nil?
349
- smart_quotes = false
349
+ if smart_quotes.nil?
350
+ if (target_coding && target_coding =~ /ascii/) || $options.v3
351
+ smart_quotes = false
352
+ end
350
353
  end
351
354
  if smart_quotes == false
352
355
  smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
@@ -359,6 +362,28 @@ when nil, true
359
362
  else
360
363
  warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
361
364
  end
365
+ if typographic_symbols.nil?
366
+ if (target_coding && target_coding =~ /ascii/) || $options.v3
367
+ typographic_symbols = false
368
+ end
369
+ end
370
+ if typographic_symbols == false
371
+ typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
372
+ if Symbol === v
373
+ [v.intern, k]
374
+ end
375
+ }.compact]
376
+ end
377
+ # warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
378
+ case typographic_symbols
379
+ when Hash
380
+ options[:typographic_symbols] = typographic_symbols
381
+ when nil, true
382
+ # nothin
383
+ else
384
+ warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
385
+ end
386
+
362
387
  if kramdown_options
363
388
  options.merge! kramdown_options
364
389
  end
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.3.11'
3
+ s.version = '1.3.16'
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.}
@@ -37,16 +37,27 @@ module Kramdown
37
37
  @span_parsers.unshift(:iref)
38
38
  end
39
39
 
40
- XREF_START = /\{\{(.*?)\}\}/u
40
+ XREF_START = /\{\{(?:(?:\{(.*?)\}(?:\{(.*?)\})?)|(.*?))((?:\}\})|\})/u
41
41
 
42
42
  # Introduce new {{target}} syntax for empty xrefs, which would
43
43
  # otherwise be an ugly ![!](target) or ![ ](target)
44
44
  # (I'd rather use [[target]], but that somehow clashes with links.)
45
45
  def parse_xref
46
46
  @src.pos += @src.matched_size
47
- href = @src[1]
48
- href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
49
- el = Element.new(:xref, nil, {'target' => href})
47
+ unless @src[4] == "}}"
48
+ warn "*** #{@src[0]}: unmatched braces #{@src[4].inspect}"
49
+ end
50
+ if contact_name = @src[1]
51
+ attr = {'fullname' => contact_name}
52
+ if ascii_name = @src[2]
53
+ attr["asciiFullname"] = ascii_name
54
+ end
55
+ el = Element.new(:contact, nil, attr)
56
+ else
57
+ href = @src[3]
58
+ href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
59
+ el = Element.new(:xref, nil, {'target' => href})
60
+ end
50
61
  @tree.children << el
51
62
  end
52
63
  define_parser(:xref, XREF_START, '{{')
@@ -403,7 +414,7 @@ COLORS
403
414
  vspace = opts[:vspace]
404
415
  vspaceel = "<vspace blankLines='#{vspace}'/>" if vspace
405
416
  ht = escape_html(inner(el, indent, opts), :attribute) # XXX this may leave gunk
406
- "#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText='#{ht}'>#{vspaceel}\n"
417
+ "#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText=\"#{ht}\">#{vspaceel}\n"
407
418
  end
408
419
 
409
420
  HTML_TAGS_WITH_BODY=['div', 'script']
@@ -524,6 +535,10 @@ COLORS
524
535
  end
525
536
  end
526
537
 
538
+ def convert_contact(el, indent, opts)
539
+ "<contact#{el_html_attributes(el)}/>"
540
+ end
541
+
527
542
  REFCACHEDIR = ENV["KRAMDOWN_REFCACHEDIR"] || ".refcache"
528
543
 
529
544
  # warn "*** REFCACHEDIR #{REFCACHEDIR}"
@@ -710,7 +725,11 @@ COLORS
710
725
  :raquo => [::Kramdown::Utils::Entities.entity('raquo')]
711
726
  }
712
727
  def convert_typographic_sym(el, indent, opts)
713
- TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e)}.join('')
728
+ if (result = @options[:typographic_symbols][el.value])
729
+ escape_html(result, :text)
730
+ else
731
+ TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e) }.join('')
732
+ end
714
733
  end
715
734
 
716
735
  def convert_smart_quote(el, indent, opts)
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.11
4
+ version: 1.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown