Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocBook writer: output identifiers of figure blocks #8608

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Text/Pandoc/Writers/DocBook.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ blockToDocBook opts (Table _ blkCapt specs thead tbody tfoot) = do
return $ inTagsIndented tableType $ captionDoc $$
inTags True "tgroup" [("cols", tshow (length aligns))] (
coltags $$ head' $$ body')
blockToDocBook opts (Figure attr capt@(Caption _ caption) body) = do
blockToDocBook opts (Figure attr@(id', _, _) capt@(Caption _ caption) body) = do
-- TODO: probably better to handle nested figures as mediaobject
let isAcceptable = \case
Table {} -> All False
Expand All @@ -344,10 +344,13 @@ blockToDocBook opts (Figure attr capt@(Caption _ caption) body) = do
DocBook4 -> pure mempty -- docbook4 requires media
DocBook5 -> blocksToDocBook opts body
mediaobjects <- mapM toMediaobject body
version <- ask
let idAttr = [ (idName version, writerIdentifierPrefix opts <> id')
| not (T.null id') ]
Comment on lines +347 to +349
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the idAndRole function, and I think it would make sense to use it here (and anywhere else where we'd manually be constructing an id attribute).

Note also that the idAndRole function doesn't use the version-dependent idName. That should be fixed.

return $
if isEmpty $ mconcat mediaobjects
then mempty -- figures must have at least some content
else inTagsIndented "figure" $
else inTags True "figure" idAttr $
inTagsSimple "title" title $$
mconcat mediaobjects

Expand Down