diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-05-16 19:10:35 -0400 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2024-05-16 17:11:22 -0600 |
| commit | 765cd853ce1211c68083596aa4f1ed56213fc68f (patch) | |
| tree | 52c8d4df4e4f03c91c0f03f7ad5f9682c50d96da | |
| parent | 76f99eedc22a63d3017033d79ed4470b1d11d4f1 (diff) | |
backport fix for #3583 preserve repeating spaces in verbatim content in manpage output
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/converter/manpage.rb | 2 | ||||
| -rw-r--r-- | test/manpage_test.rb | 33 |
3 files changed, 34 insertions, 2 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 59f85aa0..cfdabf47 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -33,6 +33,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 diff --git a/lib/asciidoctor/converter/manpage.rb b/lib/asciidoctor/converter/manpage.rb index 726d187c..398192fa 100644 --- a/lib/asciidoctor/converter/manpage.rb +++ b/lib/asciidoctor/converter/manpage.rb @@ -699,7 +699,7 @@ allbox tab(:);' 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 diff --git a/test/manpage_test.rb b/test/manpage_test.rb index db4cf8f4..5e0bbd80 100644 --- a/test/manpage_test.rb +++ b/test/manpage_test.rb @@ -348,6 +348,37 @@ context 'Manpage' do 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} @@ -818,7 +849,7 @@ context 'Manpage' do .sp .nf b - c _d_ + c\& _d_ \&. .fi T} |
