Capture alt-text
in JATS figures (#7703)
Co-authored-by: Aner Lucero <4rgento@gmail.com>
This commit is contained in:
parent
db9a73c842
commit
96a4bbe264
2 changed files with 31 additions and 2 deletions
|
@ -35,6 +35,7 @@ import Text.Pandoc.XML.Light
|
|||
import qualified Data.Set as S (fromList, member)
|
||||
import Data.Set ((\\))
|
||||
import Text.Pandoc.Sources (ToSources(..), sourcesToText)
|
||||
import qualified Data.Foldable as DF
|
||||
|
||||
type JATS m = StateT JATSState m
|
||||
|
||||
|
@ -226,9 +227,19 @@ parseBlock (Elem e) =
|
|||
mapM getInlines
|
||||
(filterChildren (const True) t)
|
||||
Nothing -> return mempty
|
||||
img <- getGraphic (Just (capt, attrValue "id" e)) g
|
||||
return $ para img
|
||||
|
||||
let figAttributes = DF.toList $
|
||||
("alt", ) . strContent <$>
|
||||
filterChild (named "alt-text") e
|
||||
|
||||
return $ simpleFigureWith
|
||||
(attrValue "id" e, [], figAttributes)
|
||||
capt
|
||||
(attrValue "href" g)
|
||||
(attrValue "title" g)
|
||||
|
||||
_ -> divWith (attrValue "id" e, ["fig"], []) <$> getBlocks e
|
||||
|
||||
parseTable = do
|
||||
let isCaption x = named "title" x || named "caption" x
|
||||
capt <- case filterChild isCaption e of
|
||||
|
|
18
test/command/jats-figure-alt-text.md
Normal file
18
test/command/jats-figure-alt-text.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
```
|
||||
% pandoc -f jats -t native
|
||||
<fig id="fig-1">
|
||||
<caption>
|
||||
<p>bar</p>
|
||||
</caption>
|
||||
<alt-text>alternative-decription</alt-text>
|
||||
<graphic xlink:href="foo.png" xlink:alt-text="baz" />
|
||||
</fig>
|
||||
^D
|
||||
[ Para
|
||||
[ Image
|
||||
( "fig-1" , [] , [ ( "alt" , "alternative-decription" ) ] )
|
||||
[ Str "bar" ]
|
||||
( "foo.png" , "fig:" )
|
||||
]
|
||||
]
|
||||
```
|
Loading…
Add table
Reference in a new issue