Skip to content

Commit 01baf8f

Browse files
committed
fixes for nested-list-marker-indent option
1 parent d6b33f3 commit 01baf8f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/kramdown-asciidoc/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def parse args
7575
options[:auto_links] = auto_links
7676
end
7777

78-
opts.on '--nested-list-marker-indent', 'Set how many spaces to indent nested list markers per indent level (default: 1)' do |nested_list_marker_indent|
78+
opts.on '--nested-list-marker-indent=NUMBER', ::Integer, 'Set how many spaces to indent nested list markers per indent level (default: 1)' do |nested_list_marker_indent|
7979
options[:nested_list_marker_indent] = nested_list_marker_indent
8080
end
8181

lib/kramdown-asciidoc/converter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def initialize root, opts
9292
@ids_seen = {}
9393
@footnote_ids = ::Set.new
9494
@auto_links = opts.fetch :auto_links, true
95-
@nested_list_marker_indent = opts[:nested_list_marker_indent] || 1
95+
@nested_list_marker_indent = [opts[:nested_list_marker_indent] || 1, 0].max
9696
@diagram_languages = opts[:diagram_languages] || %w(plantuml mermaid)
9797
@heading_offset = opts[:heading_offset] || 0
9898
@imagesdir = opts[:imagesdir] || @attributes['imagesdir']
@@ -339,7 +339,7 @@ def convert_li el, opts
339339
remaining = children
340340
primary_lines = ['{blank}']
341341
end
342-
primary_lines.unshift %(#{indent > 0 ? ' ' * indent * @nested_list_marker_indent : ''}#{marker * level} #{primary_lines.shift})
342+
primary_lines.unshift %(#{indent > 0 ? ' ' * (indent * @nested_list_marker_indent) : ''}#{marker * level} #{primary_lines.shift})
343343
writer.add_lines primary_lines
344344
return if remaining.empty?
345345
if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }

spec/cli_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,28 +204,28 @@
204204
it 'does not indent ul list markers with --nested-list-marker-indent set to 0' do
205205
the_source_file = scenario_file 'ul/nested-0-indent.md'
206206
expected = File.read (scenario_file 'ul/nested-0-indent.adoc'), mode: 'rb'
207-
(expect subject.run %W(-o - #{the_source_file})).to eql 0
207+
(expect subject.run %W(-o - --nested-list-marker-indent=0 #{the_source_file})).to eql 0
208208
(expect $stdout.string).to eql expected
209209
end
210210

211211
it 'does not indent ol list markers with --nested-list-marker-indent set to 0' do
212212
the_source_file = scenario_file 'ol/nested-0-indent.md'
213213
expected = File.read (scenario_file 'ol/nested-0-indent.adoc'), mode: 'rb'
214-
(expect subject.run %W(-o - #{the_source_file})).to eql 0
214+
(expect subject.run %W(-o - --nested-list-marker-indent=0 #{the_source_file})).to eql 0
215215
(expect $stdout.string).to eql expected
216216
end
217217

218218
it 'does indent ul list markers according to --nested-list-marker-indent configuration' do
219219
the_source_file = scenario_file 'ul/nested-3-indent.md'
220220
expected = File.read (scenario_file 'ul/nested-3-indent.adoc'), mode: 'rb'
221-
(expect subject.run %W(-o - #{the_source_file})).to eql 0
221+
(expect subject.run %W(-o - --nested-list-marker-indent=3 #{the_source_file})).to eql 0
222222
(expect $stdout.string).to eql expected
223223
end
224224

225225
it 'does indent ol list markers according to --nested-list-marker-indent configuration' do
226226
the_source_file = scenario_file 'ol/nested-3-indent.md'
227227
expected = File.read (scenario_file 'ol/nested-3-indent.adoc'), mode: 'rb'
228-
(expect subject.run %W(-o - #{the_source_file})).to eql 0
228+
(expect subject.run %W(-o - --nested-list-marker-indent=3 #{the_source_file})).to eql 0
229229
(expect $stdout.string).to eql expected
230230
end
231231

0 commit comments

Comments
 (0)