Skip to content

Commit

Permalink
resolves #3583 preserve repeating spaces in verbatim content in manpa…
Browse files Browse the repository at this point in the history
…ge output (PR #4592)
  • Loading branch information
mojavelinux committed May 16, 2024
1 parent ad827b1 commit bd84a0c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Bug Fixes::
* Don't crash when parsing xref shorthand if target starts with URL protocol and text is offset by space (#4570)
* Only drop current row if colspan of last cell exceeds specified number of columns (#4587)
* Drop last row if colspan of last cell in table exceeds specified number of columns (#4587)
* Preserve repeating spaces in verbatim content in manpage output (#3583)

== 2.0.22 (2024-03-08) - @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 @@ -698,7 +698,7 @@ def append_footnotes result, node
def manify str, opts = {}
case opts.fetch :whitespace, :collapse
when :preserve
str = str.gsub TAB, ET
str = (str.gsub TAB, ET).gsub(/(^)? +/) { $1 ? $& : %(#{ESC_BS}&#{$&}) }
when :normalize
str = str.gsub WrappedIndentRx, LF
else
Expand Down
33 changes: 32 additions & 1 deletion test/manpage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,37 @@
assert_includes output, %(Oh, here it goes again\nI should have known,\nshould have known,\nshould have known again)
end

test 'should escape repeated spaces in literal content' do
input = <<~EOS.chop
#{SAMPLE_MANPAGE_HEADER}
....
,---. ,-----.
|Bob| |Alice|
`-+-' `--+--'
| hello |
|-------------->|
,-+-. ,--+--.
|Bob| |Alice|
`---' `-----'
....
EOS

output = Asciidoctor.convert input, backend: :manpage
assert_includes output, <<~'EOS'
.fam C
,\-\-\-.\& ,\-\-\-\-\-.
|Bob|\& |Alice|
`\-+\-\*(Aq\& `\-\-+\-\-\*(Aq
|\& hello\& |
|\-\-\-\-\-\-\-\-\-\-\-\-\-\->|
,\-+\-.\& ,\-\-+\-\-.
|Bob|\& |Alice|
`\-\-\-\*(Aq\& `\-\-\-\-\-\*(Aq
.fam
EOS
end

test 'should preserve break between paragraphs in normal table cell' do
input = <<~EOS.chop
#{SAMPLE_MANPAGE_HEADER}
Expand Down Expand Up @@ -859,7 +890,7 @@
T}:T{
.nf
b
c _d_
c\& _d_
\&.
.fi
T}
Expand Down

0 comments on commit bd84a0c

Please sign in to comment.