Skip to content

Commit

Permalink
Merge pull request #1094 from skipkayhil/hm-fix-md-label-list-newlines
Browse files Browse the repository at this point in the history
Fix ToMarkdown missing newlines for label-lists
  • Loading branch information
nobu authored Mar 8, 2024
2 parents 4275958 + c652664 commit 5b8dca6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/rdoc/markup/to_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def handle_regexp_HARD_BREAK target
# Finishes consumption of `list`

def accept_list_end list
@res << "\n"

super
end

Expand All @@ -60,6 +58,8 @@ def accept_list_item_end list_item
when :NOTE, :LABEL then
use_prefix

@res << "\n"

4
else
@list_index[-1] = @list_index.last.succ
Expand All @@ -81,11 +81,11 @@ def accept_list_item_start list_item
attributes(label).strip
end.join "\n"

bullets << "\n:"
bullets << "\n" unless bullets.empty?

@prefix = ' ' * @indent
@indent += 4
@prefix << bullets + (' ' * (@indent - 1))
@prefix << bullets << ":" << (' ' * (@indent - 1))
else
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
@prefix = (' ' * @indent) + bullet.ljust(4)
Expand Down
7 changes: 2 additions & 5 deletions test/rdoc/test_rdoc_markup_to_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def accept_list_item_end_bullet
end

def accept_list_item_end_label
assert_equal "cat\n: ", @to.res.join
assert_equal "cat\n: \n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end

Expand All @@ -79,7 +79,7 @@ def accept_list_item_end_lalpha
end

def accept_list_item_end_note
assert_equal "cat\n: ", @to.res.join
assert_equal "cat\n: \n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end

Expand Down Expand Up @@ -319,9 +319,7 @@ def list_nested
expected = <<-EXPECTED
* l1
* l1.1
* l2
EXPECTED

assert_equal expected, @to.end_accepting
Expand All @@ -343,7 +341,6 @@ def list_verbatim
* second
EXPECTED

assert_equal expected, @to.end_accepting
Expand Down

0 comments on commit 5b8dca6

Please sign in to comment.