Skip to content

Commit 5b8dca6

Browse files
authored
Merge pull request #1094 from skipkayhil/hm-fix-md-label-list-newlines
Fix ToMarkdown missing newlines for label-lists
2 parents 4275958 + c652664 commit 5b8dca6

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lib/rdoc/markup/to_markdown.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def handle_regexp_HARD_BREAK target
4545
# Finishes consumption of `list`
4646

4747
def accept_list_end list
48-
@res << "\n"
49-
5048
super
5149
end
5250

@@ -60,6 +58,8 @@ def accept_list_item_end list_item
6058
when :NOTE, :LABEL then
6159
use_prefix
6260

61+
@res << "\n"
62+
6363
4
6464
else
6565
@list_index[-1] = @list_index.last.succ
@@ -81,11 +81,11 @@ def accept_list_item_start list_item
8181
attributes(label).strip
8282
end.join "\n"
8383

84-
bullets << "\n:"
84+
bullets << "\n" unless bullets.empty?
8585

8686
@prefix = ' ' * @indent
8787
@indent += 4
88-
@prefix << bullets + (' ' * (@indent - 1))
88+
@prefix << bullets << ":" << (' ' * (@indent - 1))
8989
else
9090
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
9191
@prefix = (' ' * @indent) + bullet.ljust(4)

test/rdoc/test_rdoc_markup_to_markdown.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def accept_list_item_end_bullet
6969
end
7070

7171
def accept_list_item_end_label
72-
assert_equal "cat\n: ", @to.res.join
72+
assert_equal "cat\n: \n", @to.res.join
7373
assert_equal 0, @to.indent, 'indent'
7474
end
7575

@@ -79,7 +79,7 @@ def accept_list_item_end_lalpha
7979
end
8080

8181
def accept_list_item_end_note
82-
assert_equal "cat\n: ", @to.res.join
82+
assert_equal "cat\n: \n", @to.res.join
8383
assert_equal 0, @to.indent, 'indent'
8484
end
8585

@@ -319,9 +319,7 @@ def list_nested
319319
expected = <<-EXPECTED
320320
* l1
321321
* l1.1
322-
323322
* l2
324-
325323
EXPECTED
326324

327325
assert_equal expected, @to.end_accepting
@@ -343,7 +341,6 @@ def list_verbatim
343341
344342
* second
345343
346-
347344
EXPECTED
348345

349346
assert_equal expected, @to.end_accepting

0 commit comments

Comments
 (0)