kramdown-rfc2629 1.7.39 → 1.7.40

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: 38aca91cefd454730d8c954f9d5d07035bca1a239fb1f580ab9d0d5fd41a60f3
4
- data.tar.gz: 2eda7764ffdaef67e83376c0d748fa3b5a5d95db9655662454a63d5bda9ae4c0
3
+ metadata.gz: 8169f0e77f49dec5dd3ebe8880bb1329ed159ea5553d76f68eb4ff3d9425f8e4
4
+ data.tar.gz: dbd77ffa24df6367900d97eb5835abfd0bc1fb3164865718e3e5b48b91251c09
5
5
  SHA512:
6
- metadata.gz: daca417b970b16cfdb61685947a38ec857dbf332259815a609ea54bac9959969dfa9ad0e5b392ac2a60616f0ca7ff51f9cb78f1238f04080cbb307dd7f0de9ca
7
- data.tar.gz: fc157fa46ff9ea8ef0fc69689c14f35cfd09782fc0440a9815a706c7ddccc21e5035510b4b80a696c987bd392739fe1ab46661f3707aad2a9870ba7bbd8f3b1e
6
+ metadata.gz: 8fe768ffe85a62f7a2d15e976f5e00403d7aeaca282276d1ce4ddbe788c29b2fc6beb4edab9c93c817589b589ec1af68ebb2b50d1b9c6b05fa5bbc8d71090553
7
+ data.tar.gz: 862c708667b6cc2d62de66eec9254b16ba2395afd5d0e109e72e6baa1ac78c737c1ffe1c7d2e977f005ddd7d10de97706daf2e4448b46886061198bf918b3542
data/README.md CHANGED
@@ -12,10 +12,11 @@ Who would care? Anybody who is writing Internet-Drafts and RFCs in
12
12
  the [IETF][] and prefers (or has co-authors who prefer) to do part of
13
13
  their work in markdown.
14
14
 
15
- kramdown-rfc is documented on this page, and also on
16
- [the wiki][].
15
+ kramdown-rfc is documented on this page, as well as on
16
+ [the wiki][] and via a "[Rosetta Stone]" maintained by the RFC Production Center.
17
17
 
18
18
  [the wiki]: https://github.com/cabo/kramdown-rfc/wiki
19
+ [Rosetta Stone]: https://authors.ietf.org/en/rfcxml-markdown-syntax-tables
19
20
 
20
21
  # Usage
21
22
 
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.7.39'
3
+ s.version = '1.7.40'
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.}
@@ -65,11 +65,8 @@ def process_includes(input)
65
65
  $2)
66
66
  when "data"
67
67
  data = true
68
- when /\Afold(?<columns>\d*)(?<hard>hard)?(?<left>left(?<spaces>\d*))?(?<dry>dry)?\z/
69
- md = Regexp.last_match
70
- columns = md[:columns].to_i
71
- left = md[:spaces].to_i if md[:left]
72
- fold = [columns, left, md[:dry], md[:hard]]
68
+ when ::FOLD8792_PROC_RE
69
+ fold = fold8792_options(Regexp.last_match)
73
70
  when "all", "last"
74
71
  fn_in = fn
75
72
  fn = fn.flat_map{|n| Dir[n]}
@@ -22,6 +22,13 @@ end
22
22
 
23
23
  FOLD_MSG = "NOTE: '\\' line wrapping per RFC 8792".freeze
24
24
  UNFOLD_RE = /\A.*#{FOLD_MSG.sub("\\", "(\\\\\\\\\\\\\\\\?)")}.*\n\r?\n/
25
+ # use indent as preferred synonym over smart
26
+ FOLD8792_PROC_RE = /\Afold(?<columns>\d*)(?<hard>hard)?(?:(?<indent_type>left|smart|indent)(?<spaces>\d*))?(?<dry>dry)?\z/
27
+
28
+ def fold8792_options(md)
29
+ indent_type = md[:indent_type].to_sym if md[:indent_type]
30
+ [md[:columns].to_i, indent_type, (md[:spaces] || 0).to_i, md[:dry], md[:hard]]
31
+ end
25
32
 
26
33
  def unfold8792(s)
27
34
  if s =~ UNFOLD_RE
@@ -44,7 +51,7 @@ MIN_FOLD_COLUMNS = FOLD_MSG.size
44
51
  FOLD_COLUMNS = 69
45
52
  RE_IDENT = /\A[A-Za-z0-9_]\z/
46
53
 
47
- def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = false)
54
+ def fold8792_1(s, columns = FOLD_COLUMNS, indent_type = nil, indent_spaces = 0, dry = false, hard = false)
48
55
  if s.index("\t")
49
56
  warn "*** HT (\"TAB\") in text to be folded. Giving up."
50
57
  return s
@@ -61,6 +68,7 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
61
68
 
62
69
  lines = s.lines.map(&:chomp)
63
70
  did_fold = false
71
+ smart_indent = nil
64
72
  ix = 0
65
73
  while li = lines[ix]
66
74
  col = columns
@@ -69,16 +77,26 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
69
77
  lines[ix..ix] = [li << "\\", ""]
70
78
  ix += 1
71
79
  end
80
+ smart_indent = nil
72
81
  ix += 1
73
82
  else
74
83
  did_fold = true
75
- min_indent = left || 0
84
+ left_indent =
85
+ case indent_type
86
+ when :left
87
+ indent_spaces
88
+ when :smart, :indent
89
+ smart_indent ||= li[/\A */].size + indent_spaces
90
+ end
91
+ min_indent = left_indent || 0
76
92
  col -= 1 # space for "\\"
77
93
  while li[col] == " " # can't start new line with " "
78
94
  col -= 1
79
95
  end
80
96
  if col <= min_indent
81
- warn "*** Cannot RFC8792-fold1 to #{columns} cols #{"with indent #{left}" if left} |#{li.inspect}|"
97
+ indent_msg = "with indent #{min_indent}" if indent_type
98
+ warn "*** Cannot RFC8792-fold1 to #{columns} cols #{indent_msg} |#{li.inspect}|"
99
+ smart_indent = nil
82
100
  else
83
101
  if !hard && RE_IDENT === li[col] # Don't split IDs
84
102
  col2 = col
@@ -90,8 +108,8 @@ def fold8792_1(s, columns = FOLD_COLUMNS, left = false, dry = false, hard = fals
90
108
  end
91
109
  end
92
110
  rest = li[col..-1]
93
- indent = left || columns - rest.size
94
- if !left && li[-1] == "\\"
111
+ indent = left_indent || columns - rest.size
112
+ if !left_indent && li[-1] == "\\"
95
113
  indent -= 1 # leave space for next round
96
114
  end
97
115
  if indent > 0
@@ -795,11 +795,8 @@ COLORS
795
795
  case proc
796
796
  when "dedent"
797
797
  result = remove_indentation(result)
798
- when /\Afold(?<columns>\d*)(?<hard>hard)?(?<left>left(?<spaces>\d*))?(?<dry>dry)?\z/
799
- md = Regexp.last_match
800
- columns = md[:columns].to_i
801
- left = md[:spaces].to_i if md[:left]
802
- fold = [columns, left, md[:dry], md[:hard]]
798
+ when ::FOLD8792_PROC_RE
799
+ fold = fold8792_options(Regexp.last_match)
803
800
  result = fix_unterminated_line(fold8792_1(trim_empty_lines_around(result), *fold)) # XXX
804
801
  when /\Alines(\d*)\.\.(\.)?(\d*)\z/
805
802
  range = Range.new($1.empty? ? nil : $1.to_i, # compensate for
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.39
4
+ version: 1.7.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann