kramdown 2.3.2 → 2.4.0

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: f656918e531f3b20c720da64a979ea287aabf5e9b2a9bb18599d968957926e41
4
- data.tar.gz: 3150331b7195b4dd186984a301a174ca0943e85ad11c3aef47b797b9dd46ad58
3
+ metadata.gz: 3c41b216fbd6f50c68b10864bc3a98040f79641db9af8ced05eb43f7817335ad
4
+ data.tar.gz: ef3adb19cbfbe4586bf0ef4f14362ca843a7fe3331ff6dc990c270ff65cff000
5
5
  SHA512:
6
- metadata.gz: d7b0d8a7af60a0c72a6a49b26a05fc8fe3c348458802f489891166711aad985d0240d8b8882432d81ba6a061fd78e5c598ddc6dd6fa5f5de7b1aa57cf5fc9514
7
- data.tar.gz: bec4c4bb4705f28db0bc4b7f3e4f6105e531a8711870edd90f36b0e270a653305bef544116760d3748ef91f112d51e666b468c38cddc116bcdf8c1267fbab1d3
6
+ metadata.gz: 483e269f858aadd6bf8e7bf2f49ec90ddfdcd9628aec17822eb7eefcfc21897eb19d258a84b6291611a38a5958a79013c2c656d35f7740b116923bd8624a2329
7
+ data.tar.gz: 5ffeef35cdfb994411414d62bd8b5fcf09fcea7d926069896248148575b88b4abbfdc1e5aab6da8dbe6f97c3e0a4921b391802e391ea3c76a646be7f64fbbbda
data/CONTRIBUTERS CHANGED
@@ -1,6 +1,6 @@
1
1
  Count Name
2
2
  ======= ====
3
- 960 Thomas Leitner <t_leitner@gmx.at>
3
+ 964 Thomas Leitner <t_leitner@gmx.at>
4
4
  18 Ashwin Maroli <ashmaroli@gmail.com>
5
5
  7 Christian Cornelssen <ccorn@1tein.de>
6
6
  6 Gioele Barabucci <gioele@svario.it>
@@ -11,6 +11,7 @@
11
11
  4 Arne Brasseur <arne@arnebrasseur.net>
12
12
  3 Henning Perl <perl@fast-sicher.de>
13
13
  3 gettalong <t_leitner@gmx.at>
14
+ 3 Carsten Bormann <cabo@tzi.org>
14
15
  3 Brandur <brandur@mutelight.org>
15
16
  3 Ben Armston <ben.armston@googlemail.com>
16
17
  3 Ashwin Maroli <ashmaroli@users.noreply.github.com>
@@ -20,7 +21,6 @@
20
21
  2 Nathanael Jones <nathanael.jones@gmail.com>
21
22
  2 Max Meyer <dev@fedux.org>
22
23
  2 Jo Hund <jhund@clearcove.ca>
23
- 2 Carsten Bormann <cabo@tzi.org>
24
24
  2 Bran <m.versum@gmail.com>
25
25
  1 winniehell <git@winniehell.de>
26
26
  1 William <suttonwilliamd@gmail.com>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.2
1
+ 2.4.0
@@ -283,7 +283,7 @@ module Kramdown
283
283
  hl_opts = {}
284
284
  result = highlight_code(el.value, lang, :span, hl_opts)
285
285
  if result
286
- add_syntax_highlighter_to_class_attr(attr, hl_opts[:default_lang])
286
+ add_syntax_highlighter_to_class_attr(attr, lang || hl_opts[:default_lang])
287
287
  else
288
288
  result = escape_html(el.value)
289
289
  end
@@ -27,6 +27,8 @@ module Kramdown
27
27
  @footnotes = []
28
28
  @abbrevs = []
29
29
  @stack = []
30
+ @list_indent = @options[:list_indent]
31
+ @list_spacing = ' ' * (@list_indent - 2)
30
32
  end
31
33
 
32
34
  def convert(el, opts = {indent: 0})
@@ -77,7 +79,9 @@ module Kramdown
77
79
  else
78
80
  el.value.gsub(/\A\n/) do
79
81
  opts[:prev] && opts[:prev].type == :br ? '' : "\n"
80
- end.gsub(/\s+/, ' ').gsub(ESCAPED_CHAR_RE) { "\\#{$1 || $2}" }
82
+ end.gsub(/\s+/, ' ').gsub(ESCAPED_CHAR_RE) do
83
+ $1 || !opts[:prev] || opts[:prev].type == :br ? "\\#{$1 || $2}" : $&
84
+ end
81
85
  end
82
86
  end
83
87
 
@@ -87,6 +91,7 @@ module Kramdown
87
91
  first&.gsub!(/^(?:(#|>)|(\d+)\.|([+-]\s))/) { $1 || $3 ? "\\#{$1 || $3}" : "#{$2}\\." }
88
92
  second&.gsub!(/^([=-]+\s*?)$/, "\\\1")
89
93
  res = [first, second, *rest].compact.join("\n") + "\n"
94
+ res.gsub!(/^[ ]{0,3}:/, "\\:")
90
95
  if el.children.length == 1 && el.children.first.type == :math
91
96
  res = "\\#{res}"
92
97
  elsif res.start_with?('\$$') && res.end_with?("\\$$\n")
@@ -124,7 +129,7 @@ module Kramdown
124
129
 
125
130
  def convert_li(el, opts)
126
131
  sym, width = if @stack.last.type == :ul
127
- [+'* ', el.children.first && el.children.first.type == :codeblock ? 4 : 2]
132
+ ['* ' + @list_spacing, el.children.first && el.children.first.type == :codeblock ? 4 : @list_indent]
128
133
  else
129
134
  ["#{opts[:index] + 1}.".ljust(4), 4]
130
135
  end
@@ -151,7 +156,7 @@ module Kramdown
151
156
  end
152
157
 
153
158
  def convert_dd(el, opts)
154
- sym, width = +": ", (el.children.first && el.children.first.type == :codeblock ? 4 : 2)
159
+ sym, width = ": " + @list_spacing, (el.children.first && el.children.first.type == :codeblock ? 4 : @list_indent)
155
160
  if (ial = ial_for_element(el))
156
161
  sym << ial << " "
157
162
  end
@@ -605,6 +605,13 @@ module Kramdown
605
605
  simple_array_validator(val, :forbidden_inline_options)
606
606
  end
607
607
 
608
+ define(:list_indent, Integer, 2, <<~EOF)
609
+ Sets the number of spaces to use for list indentation
610
+
611
+ Default: 2
612
+ Used by: Kramdown converter
613
+ EOF
614
+
608
615
  end
609
616
 
610
617
  end
@@ -10,6 +10,6 @@
10
10
  module Kramdown
11
11
 
12
12
  # The kramdown version.
13
- VERSION = '2.3.2'
13
+ VERSION = '2.4.0'
14
14
 
15
15
  end
data/man/man1/kramdown.1 CHANGED
@@ -174,6 +174,13 @@ If the value is a String, it has to contain a valid YAML hash and the hash has t
174
174
  Default: {} Used by: kramdown parser
175
175
  .RE
176
176
  .TP
177
+ \fB\-\-list\-indent\fP \fIARG\fP
178
+ Sets the number of spaces to use for list indentation
179
+ .RS
180
+ .P
181
+ Default: 2 Used by: Kramdown converter
182
+ .RE
183
+ .TP
177
184
  \fB\-\-math\-engine\fP \fIARG\fP
178
185
  Set the math engine
179
186
  .RS
data/test/test_files.rb CHANGED
@@ -197,6 +197,9 @@ class TestFiles < Minitest::Test
197
197
  kdtext = Kramdown::Document.new(File.read(text_file), options).to_kramdown
198
198
  html = Kramdown::Document.new(kdtext, options).to_html
199
199
  assert_equal(tidy_output(File.read(html_file)), tidy_output(html))
200
+ kdtext4 = Kramdown::Document.new(File.read(text_file), options.merge({list_indent: 4})).to_kramdown
201
+ html = Kramdown::Document.new(kdtext4, options).to_html
202
+ assert_equal(tidy_output(File.read(html_file)), tidy_output(html))
200
203
  end
201
204
  end
202
205
  end
@@ -0,0 +1,7 @@
1
+ aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa
2
+ \: No definiion list
3
+
4
+ a:
5
+
6
+ *a*:
7
+
@@ -0,0 +1,5 @@
1
+ aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa : No definiion list
2
+
3
+ a:
4
+
5
+ *a*:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-18 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rexml
@@ -170,6 +170,8 @@ files:
170
170
  - test/testcases/block/03_paragraph/one_para.text
171
171
  - test/testcases/block/03_paragraph/standalone_image.html
172
172
  - test/testcases/block/03_paragraph/standalone_image.text
173
+ - test/testcases/block/03_paragraph/to_kramdown.kramdown
174
+ - test/testcases/block/03_paragraph/to_kramdown.text
173
175
  - test/testcases/block/03_paragraph/two_para.html
174
176
  - test/testcases/block/03_paragraph/two_para.text
175
177
  - test/testcases/block/03_paragraph/with_html_to_native.html