kramdown-rfc2629 1.5.24 → 1.5.25

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: d7c7ac571f000360c4b8aca5450e5439c2d50b71fb85872ad2890e575c986c9b
4
- data.tar.gz: 1af9f4b9d49c2176143a61b7c24f3bc9f13302a2bbef6a5cc90a379596b5ff04
3
+ metadata.gz: 4e19def630ee2ad018b297cd5c196e3ee70f052fea88004014a1e8dcc298c050
4
+ data.tar.gz: eb677f68752221d001095424394b4d276453614bb2286fe77e83d2d3a41d1cfa
5
5
  SHA512:
6
- metadata.gz: 58d5ed0d4e9ec45f285a2230055a5cdbc4393a0eec6fe5722c170a965a4d24a6f5a73bf16e14e83b38fa6029a6942edacf88f5621f2e2c5c0aabd2223f73bc9f
7
- data.tar.gz: 748fbf3adced720c4cdb48c346174d4660a17b670ee5f12fc315fd252d3353c7e8c8569bba1d4526f2c8016c85d524160e9bfac5749f3e1f40b7932c048d3a01
6
+ metadata.gz: f54b8a10cb72d16313a4a5c644e52e223539f38b4245d6ca3e54abb28b1704bdbd447d15b0065ad00334df6bbae3a0508f08cd59f0eaf37bfaa717eb52b394ff
7
+ data.tar.gz: b54e739cba1b21727189cfdf576fc0d8f0bcac1be224bf7affb017c1ddcfd0e2358344a1f162763183b297da2256ca9710e64946b62f79e2e1aa65ec45bdab04
data/bin/kramdown-rfc2629 CHANGED
@@ -28,13 +28,13 @@ end
28
28
  def process_chunk(s, nested, dedent, fold, quote)
29
29
  process_includes(s) if nested
30
30
  s = remove_indentation(s) if dedent
31
- s = fold8792_1(s) if fold
31
+ s = fold8792_1(s, *fold) if fold
32
32
  s = add_quote(s) if quote
33
33
  s
34
34
  end
35
35
 
36
36
  def process_includes(input)
37
- input.gsub!(/^\{::include((?:-[a-z]+)*)\s+(.*?)\}/) {
37
+ input.gsub!(/^\{::include((?:-[a-z0-9]+)*)\s+(.*?)\}/) {
38
38
  include_flags = $1
39
39
  fn = [$2]
40
40
  chunks = false
@@ -51,8 +51,10 @@ def process_includes(input)
51
51
  quote = true
52
52
  when "dedent"
53
53
  dedent = true
54
- when "fold"
55
- fold = true
54
+ when /\Afold(\d*)(left(\d*))?(dry)?\z/
55
+ fold = [$1.to_i, # col 0 for ''
56
+ ($3.to_i if $2), # left 0 for '', nil if no "left"
57
+ $4] # dry
56
58
  when "all", "last"
57
59
  fn = fn.flat_map{|n| Dir[n]}
58
60
  fn = [fn.last] if flag == "last"
@@ -1,9 +1,18 @@
1
1
  <?xml version="1.0" encoding="<%=ps[:coding]||"UTF-8"%>"?>
2
2
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
3
3
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version <%=
4
- Gem.loaded_specs["kramdown-rfc2629"].version rescue nil %> -->
5
-
4
+ Gem.loaded_specs["kramdown-rfc2629"].version rescue nil
5
+ %> (Ruby <%= RUBY_VERSION %>) -->
6
+
7
+ <% if $options.v3 %>
8
+ <!DOCTYPE rfc <%= ps["doctype-reference"] %> [
9
+ <!ENTITY nbsp "&#160;">
10
+ <!ENTITY zwsp "&#8203;">
11
+ <!ENTITY nbhy "&#8209;">
12
+ <!ENTITY wj "&#8288;">
13
+ <% else %>
6
14
  <!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
15
+ <% end %>
7
16
  <% ps.arr("bibxml") do |tag, sys| -%>
8
17
  <!ENTITY <%= tag %> SYSTEM "<%= sys %>">
9
18
  <% end -%>
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.5.24'
3
+ s.version = '1.5.25'
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.}
@@ -1,11 +1,22 @@
1
+ FOLD_MSG = "NOTE: '\\' line wrapping per RFC 8792".freeze
2
+ MIN_FOLD_COLUMNS = FOLD_MSG.size
1
3
  FOLD_COLUMNS = 69
2
4
  RE_IDENT = /\A[A-Za-z0-9_]\z/
3
5
 
4
- def fold8792_1(s, columns = FOLD_COLUMNS)
6
+ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false)
5
7
  if s.index("\t")
6
8
  warn "*** HT (\"TAB\") in text to be folded. Giving up."
7
9
  return s
8
10
  end
11
+ if columns < MIN_FOLD_COLUMNS
12
+ columns =
13
+ if columns == 0
14
+ FOLD_COLUMNS
15
+ else
16
+ warn "*** folding to #{MIN_FOLD_COLUMNS}, not #{columns}"
17
+ MIN_FOLD_COLUMNS
18
+ end
19
+ end
9
20
 
10
21
  lines = s.lines.map(&:chomp)
11
22
  did_fold = false
@@ -20,25 +31,26 @@ def fold8792_1(s, columns = FOLD_COLUMNS)
20
31
  ix += 1
21
32
  else
22
33
  did_fold = true
34
+ min_indent = left || 0
23
35
  col -= 1 # space for "\\"
24
36
  while li[col] == " " # can't start new line with " "
25
37
  col -= 1
26
38
  end
27
- if col <= 0
28
- warn "*** Cannot RFC8792-fold1 #{li.inspect}"
39
+ if col <= min_indent
40
+ warn "*** Cannot RFC8792-fold1 to #{columns} cols #{"with indent #{left}" if left} |#{li.inspect}|"
29
41
  else
30
42
  if RE_IDENT === li[col] # Don't split IDs
31
43
  col2 = col
32
- while col2 > 0 && RE_IDENT === li[col2-1]
44
+ while col2 > min_indent && RE_IDENT === li[col2-1]
33
45
  col2 -= 1
34
46
  end
35
- if col2 > 0
47
+ if col2 > min_indent
36
48
  col = col2
37
49
  end
38
50
  end
39
51
  rest = li[col..-1]
40
- indent = columns - rest.size
41
- if li[-1] == "\\"
52
+ indent = left || columns - rest.size
53
+ if !left && li[-1] == "\\"
42
54
  indent -= 1 # leave space for next round
43
55
  end
44
56
  if indent > 0
@@ -51,7 +63,13 @@ def fold8792_1(s, columns = FOLD_COLUMNS)
51
63
  end
52
64
 
53
65
  if did_fold
54
- lines[0...0] = ["=== NOTE: '\\' line wrapping per RFC 8792 ===", ""]
66
+ msg = FOLD_MSG.dup
67
+ if !dry && columns >= msg.size + 4
68
+ delta = columns - msg.size - 2 # 2 spaces
69
+ half = delta/2
70
+ msg = "#{"=" * half} #{msg} #{"=" * (delta - half)}"
71
+ end
72
+ lines[0...0] = [msg, ""]
55
73
  lines.map{|x| x << "\n"}.join
56
74
  else
57
75
  s
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.24
4
+ version: 1.5.25
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-12-16 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown