diff options
| author | Julia Diaz <[email protected]> | 2023-10-17 17:16:00 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-17 09:16:00 -0700 |
| commit | fa3513b104e089a8969f3ae0dab98eba78b1a942 (patch) | |
| tree | f1d89ccbf6ee52fd22ec6cc77e161da2403a54cb /src | |
| parent | 802c610923b364a4a10f59eccb5f1d0b7176ab53 (diff) | |
JATS reader: fix handling of alt-text (#9134)
Previously we were looking for an attribute that doesn't exist in
JATS; alt-text is provided by a child element.
Closes #9130.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/JATS.hs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs index fd90044af..6cadef306 100644 --- a/src/Text/Pandoc/Readers/JATS.hs +++ b/src/Text/Pandoc/Readers/JATS.hs @@ -138,18 +138,16 @@ trimNl = T.dropAround (== '\n') -- function that is used by both graphic (in parseBlock) -- and inline-graphic (in parseInline) -getGraphic :: PandocMonad m - => Maybe (Inlines, Text) -> Element -> JATS m Inlines -getGraphic mbfigdata e = do +getGraphic :: PandocMonad m => Element -> JATS m Inlines +getGraphic e = do let atVal a = attrValue a e - (ident, title, capt) = - case mbfigdata of - Just (capt', i) -> (i, "fig:" <> atVal "title", capt') - Nothing -> (atVal "id", atVal "title", - text (atVal "alt-text")) + let altText = case filterElement (named "alt-text") e of + Just alt -> textContent alt + Nothing -> mempty + (ident, title, altText') = (atVal "id", atVal "title", text altText) attr = (ident, T.words $ atVal "role", []) imageUrl = atVal "href" - return $ imageWith attr imageUrl title capt + return $ imageWith attr imageUrl title altText' getBlocks :: PandocMonad m => Element -> JATS m Blocks getBlocks e = mconcat <$> @@ -198,7 +196,7 @@ parseBlock (Elem e) = do "table-wrap-foot" -> parseBlockWithHeader "trans-abstract" -> parseBlockWithHeader "verse-group" -> parseBlockWithHeader - "graphic" -> para <$> getGraphic Nothing e + "graphic" -> para <$> getGraphic e "journal-meta" -> parseMetadata e "article-meta" -> parseMetadata e "custom-meta" -> parseMetadata e @@ -622,7 +620,7 @@ parseInline (Elem e) = "code" -> codeWithLang "monospace" -> codeWithLang - "inline-graphic" -> getGraphic Nothing e + "inline-graphic" -> getGraphic e "disp-quote" -> do qt <- gets jatsQuoteType let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote |
