diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2017-06-30 23:57:38 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2017-06-30 23:57:38 -0600 |
| commit | 7ac4c7d64f50562eeb45744affe892d5b6ee4304 (patch) | |
| tree | b84fc9fc3446f156e4f914d44bae549fee5793c5 | |
| parent | 5b433bde8870f62e34cf33966ad9463ee94423a1 (diff) | |
use alt_text method in manpage converter; add tests
| -rw-r--r-- | lib/asciidoctor/converter/manpage.rb | 4 | ||||
| -rw-r--r-- | test/manpage_test.rb | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/asciidoctor/converter/manpage.rb b/lib/asciidoctor/converter/manpage.rb index aa7df83f..b6cc6166 100644 --- a/lib/asciidoctor/converter/manpage.rb +++ b/lib/asciidoctor/converter/manpage.rb @@ -626,9 +626,7 @@ allbox tab(:);' end def inline_image node - # NOTE alt should always be set - alt_text = (node.attr? 'alt') ? (node.attr 'alt') : node.target - (node.attr? 'link') ? %([#{alt_text}] <#{node.attr 'link'}>) : %([#{alt_text}]) + (node.attr? 'link') ? %([#{node.alt_text}] <#{node.attr 'link'}>) : %([#{node.alt_text}]) end def inline_indexterm node diff --git a/test/manpage_test.rb b/test/manpage_test.rb index a7220832..974532bb 100644 --- a/test/manpage_test.rb +++ b/test/manpage_test.rb @@ -287,6 +287,24 @@ T} end end + context 'Images' do + test 'should replace inline image with alt text' do + input = %(#{SAMPLE_MANPAGE_HEADER} + +The Magic 8 Ball says image:signs-point-to-yes.jpg[].) + output = Asciidoctor.convert input, :backend => :manpage + assert_includes output, 'The Magic 8 Ball says [signs point to yes].' + end + + test 'should place link after alt text for inline image if link is defined' do + input = %(#{SAMPLE_MANPAGE_HEADER} + +The Magic 8 Ball says image:signs-point-to-yes.jpg[link=https://en.wikipedia.org/wiki/Magic_8-Ball].) + output = Asciidoctor.convert input, :backend => :manpage + assert_includes output, 'The Magic 8 Ball says [signs point to yes] <https://en.wikipedia.org/wiki/Magic_8\-Ball>.' + end + end + context 'Callout List' do test 'should generate callout list using proper formatting commands' do input = %(#{SAMPLE_MANPAGE_HEADER} |
