Skip to content

Commit 94e189b

Browse files
committed
Restrict fix for #204 to HTML only
Replacing newlines with spaces in paragraphs for other output leads to missing line breaks and incorrect output.
1 parent 4698234 commit 94e189b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/rdoc/markup/paragraph.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def text hard_break = ''
2121
else
2222
part
2323
end
24-
end.join.gsub(/\r?\n/, ' ')
24+
end.join
2525
end
2626

2727
end

lib/rdoc/markup/to_html.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def accept_block_quote block_quote
176176
def accept_paragraph paragraph
177177
@res << "\n<p>"
178178
text = paragraph.text @hard_break
179+
text = text.gsub(/\r?\n/, ' ')
179180
@res << wrap(to_html(text))
180181
@res << "</p>\n"
181182
end

test/test_rdoc_markup_to_html.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,14 @@ def test_accept_heading_pipe
389389
assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
390390
end
391391

392+
def test_accept_paragraph_newline
393+
@to.start_accepting
394+
395+
@to.accept_paragraph para("hello\n", "world\n")
396+
397+
assert_equal "\n<p>hello world</p>\n", @to.res.join
398+
end
399+
392400
def test_accept_verbatim_parseable
393401
verb = @RM::Verbatim.new("class C\n", "end\n")
394402

0 commit comments

Comments
 (0)