From 349fd87f750ead8499e40c3ab05d707f293e7489 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Mon, 17 Apr 2023 14:32:48 -0600 Subject: [PATCH] backport fix for #4401 manify alt text of block image in manpage output --- CHANGELOG.adoc | 1 + lib/asciidoctor/converter/manpage.rb | 2 +- test/manpage_test.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index bff9d7d14e..c6fc7a14a3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -32,6 +32,7 @@ Bug Fixes:: * Use correct selector to collapse margin on first and last child of sidebar * Don't allow target of include directive to start with a space (to distinguish it from a dlist item) or to end with a space + * Manify alt text of block image in manpage output (#4401) == 2.0.18 (2022-10-15) - @mojavelinux diff --git a/lib/asciidoctor/converter/manpage.rb b/lib/asciidoctor/converter/manpage.rb index 6c41fbc341..71fa6a1ac2 100644 --- a/lib/asciidoctor/converter/manpage.rb +++ b/lib/asciidoctor/converter/manpage.rb @@ -236,7 +236,7 @@ def convert_image node result << (node.title? ? %(.sp .B #{manify node.captioned_title} .br) : '.sp') - result << %([#{node.alt}]) + result << %([#{manify node.alt}]) result.join LF end diff --git a/test/manpage_test.rb b/test/manpage_test.rb index 31d7a247fb..5a593996b0 100644 --- a/test/manpage_test.rb +++ b/test/manpage_test.rb @@ -765,6 +765,17 @@ assert output.end_with? %(\n.sp\n[signs point to yes]) end + test 'should manify alt text of block image' do + input = <<~EOS.chop + #{SAMPLE_MANPAGE_HEADER} + + image::rainbow.jpg["That's a double rainbow, otherwise known as rainbow{pp}!"] + EOS + + output = Asciidoctor.convert input, backend: :manpage + assert output.end_with? %/\n.sp\n[That\\(cqs a double rainbow, otherwise known as rainbow++!]/ + end + test 'should replace inline image with alt text enclosed in square brackets' do input = <<~EOS.chop #{SAMPLE_MANPAGE_HEADER}