Skip to content

Commit

Permalink
resolves asciidoctor#4481 preserve paragraph breaks in normal table c…
Browse files Browse the repository at this point in the history
…ell in manpage output
  • Loading branch information
mojavelinux committed Sep 5, 2023
1 parent 454d590 commit dc1883c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Improvements::

Bug Fixes::

* Preserve paragraph breaks in normal table cell in manpage output (#4481)
* Escape spaces in include target (using inline passthrough) when generating link from include directive (#4461)

== 2.0.20 (2023-05-18) - @mojavelinux
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/converter/manpage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def convert_table node
when :literal
cell_content = %(.nf#{LF}#{manify cell.text, whitespace: :preserve}#{LF}.fi)
else
cell_content = manify cell.content.join, whitespace: :normalize
cell_content = cell.content.map {|p| manify p, whitespace: :normalize }.join %(#{LF}.sp#{LF})
end
row_text[row_index] << %(#{cell_content}#{LF})
else # tsec == :head || tsec == :foot
Expand Down
45 changes: 45 additions & 0 deletions test/manpage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,51 @@
assert_includes output, %(Oh, here it goes again\nI should have known,\nshould have known,\nshould have known again)
end

test 'should preserve break between paragraphs in normal table cell' do
input = <<~EOS.chop
#{SAMPLE_MANPAGE_HEADER}
[cols=3*]
|===
|single paragraph
|first paragraph
second paragraph
|foo
more foo
even more foo
|===
EOS

expected_coda = <<~'EOS'.chop
.TS
allbox tab(:);
lt lt lt.
T{
.sp
single paragraph
T}:T{
.sp
first paragraph
.sp
second paragraph
T}:T{
.sp
foo
.sp
more foo
.sp
even more foo
T}
.TE
.sp
EOS
output = Asciidoctor.convert input, backend: :manpage
assert output.end_with? expected_coda
end

test 'should normalize whitespace in a list item' do
input = <<~EOS.chop
#{SAMPLE_MANPAGE_HEADER}
Expand Down

0 comments on commit dc1883c

Please sign in to comment.