Skip to content

Commit

Permalink
DocBook writer: render image alt text using textobject element.
Browse files Browse the repository at this point in the history
See #8437.
  • Loading branch information
jgm committed Nov 29, 2022
1 parent 8f9e162 commit 6a23ac0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Text/Pandoc/Writers/DocBook.hs
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,17 @@ inlineToDocBook opts (Link attr txt (src, _))
then inTags False "link" $ ("xlink:href", src) : idAndRole attr
else inTags False "ulink" $ ("url", src) : idAndRole attr )
<$> inlinesToDocBook opts txt
inlineToDocBook opts (Image attr _ (src, tit)) = return $
inlineToDocBook opts (Image attr ils (src, tit)) = return $
let titleDoc = if T.null tit
then empty
else inTagsIndented "objectinfo" $
inTagsIndented "title" (literal $ escapeStringForXML tit)
alt = if null ils
then mempty
else inTagsIndented "textobject" $
inTags False "phrase" [] $ literal (stringify ils)
in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $
titleDoc $$ imageToDocBook opts attr src
titleDoc $$ imageToDocBook opts attr src $$ alt
inlineToDocBook opts (Note contents) =
inTagsIndented "footnote" <$> blocksToDocBook opts contents

Expand Down
3 changes: 3 additions & 0 deletions test/writer.docbook4
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ or here: &lt;http://example.com/&gt;
Here is a movie <inlinemediaobject>
<imageobject>
<imagedata fileref="movie.jpg" />
<textobject>
<phrase>movie</phrase>
</textobject>
</imageobject>
</inlinemediaobject> icon.
</para>
Expand Down
3 changes: 3 additions & 0 deletions test/writer.docbook5
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,9 @@ or here: &lt;http://example.com/&gt;
Here is a movie <inlinemediaobject>
<imageobject>
<imagedata fileref="movie.jpg" />
<textobject>
<phrase>movie</phrase>
</textobject>
</imageobject>
</inlinemediaobject> icon.
</para>
Expand Down

0 comments on commit 6a23ac0

Please sign in to comment.