Skip to content

Commit

Permalink
fixes for nested-list-marker-indent option
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Mar 12, 2024
1 parent d6b33f3 commit 01baf8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/kramdown-asciidoc/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def parse args
options[:auto_links] = auto_links
end

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|
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|
options[:nested_list_marker_indent] = nested_list_marker_indent
end

Expand Down
4 changes: 2 additions & 2 deletions lib/kramdown-asciidoc/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def initialize root, opts
@ids_seen = {}
@footnote_ids = ::Set.new
@auto_links = opts.fetch :auto_links, true
@nested_list_marker_indent = opts[:nested_list_marker_indent] || 1
@nested_list_marker_indent = [opts[:nested_list_marker_indent] || 1, 0].max
@diagram_languages = opts[:diagram_languages] || %w(plantuml mermaid)
@heading_offset = opts[:heading_offset] || 0
@imagesdir = opts[:imagesdir] || @attributes['imagesdir']
Expand Down Expand Up @@ -339,7 +339,7 @@ def convert_li el, opts
remaining = children
primary_lines = ['{blank}']
end
primary_lines.unshift %(#{indent > 0 ? ' ' * indent * @nested_list_marker_indent : ''}#{marker * level} #{primary_lines.shift})
primary_lines.unshift %(#{indent > 0 ? ' ' * (indent * @nested_list_marker_indent) : ''}#{marker * level} #{primary_lines.shift})
writer.add_lines primary_lines
return if remaining.empty?
if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }
Expand Down
8 changes: 4 additions & 4 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,28 @@
it 'does not indent ul list markers with --nested-list-marker-indent set to 0' do
the_source_file = scenario_file 'ul/nested-0-indent.md'
expected = File.read (scenario_file 'ul/nested-0-indent.adoc'), mode: 'rb'
(expect subject.run %W(-o - #{the_source_file})).to eql 0
(expect subject.run %W(-o - --nested-list-marker-indent=0 #{the_source_file})).to eql 0
(expect $stdout.string).to eql expected
end

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

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

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

Expand Down

0 comments on commit 01baf8f

Please sign in to comment.