@@ -168,6 +168,13 @@ blockToJATS opts (Div ('r':'e':'f':'-':_,_,_) [Para lst]) =
168168blockToJATS opts (Div ("refs",_,_) xs) = do
169169 contents <- blocksToJATS opts xs
170170 return $ inTagsIndented "ref-list" contents
171+blockToJATS opts (Div (ident,[cls],kvs) bs) | cls `elem` ["fig", "caption", "table-wrap"] = do
172+ contents <- blocksToJATS opts bs
173+ let attr = [("id", ident) | not (null ident)] ++
174+ [("xml:lang",l) | ("lang",l) <- kvs] ++
175+ [(k,v) | (k,v) <- kvs, k `elem` ["specific-use",
176+ "content-type", "orientation", "position"]]
177+ return $ inTags True cls attr contents
171178blockToJATS opts (Div (ident,_,kvs) bs) = do
172179 contents <- blocksToJATS opts bs
173180 let attr = [("id", ident) | not (null ident)] ++
@@ -175,10 +182,9 @@ blockToJATS opts (Div (ident,_,kvs) bs) = do
175182 [(k,v) | (k,v) <- kvs, k `elem` ["specific-use",
176183 "content-type", "orientation", "position"]]
177184 return $ inTags True "boxed-text" attr contents
178−blockToJATS _ h@(Header{}) = do
179− -- should not occur after hierarchicalize, except inside lists/blockquotes
180− report $ BlockNotRendered h
181− return empty
185+blockToJATS opts (Header _ _ title) = do
186+ title' <- inlinesToJATS opts title
187+ return $ inTagsSimple "title" title'
182188-- No Plain, everything needs to be in a block-level tag
183189blockToJATS opts (Plain lst) = blockToJATS opts (Para lst)
184190-- title beginning with fig: indicates that the image is a figure
@@ -204,6 +210,24 @@ blockToJATS opts (Para [Image (ident,_,kvs) txt
204210 ("xlink:title",tit)]
205211 return $ inTags True "fig" attr $
206212 capt $$ selfClosingTag "graphic" graphicattr
213+blockToJATS _ (Para [Image (ident,_,kvs) _ (src, tit)]) = do
214+ let mbMT = getMimeType src
215+ let maintype = fromMaybe "image" $
216+ lookup "mimetype" kvs `mplus`
217+ (takeWhile (/='/') <$> mbMT)
218+ let subtype = fromMaybe "" $
219+ lookup "mime-subtype" kvs `mplus`
220+ ((drop 1 . dropWhile (/='/')) <$> mbMT)
221+ let attr = [("id", ident) | not (null ident)] ++
222+ [("mimetype", maintype),
223+ ("mime-subtype", subtype),
224+ ("xlink:href", src)] ++
225+ [("xlink:title", tit) | not (null tit)] ++
226+ [(k,v) | (k,v) <- kvs, k `elem` ["baseline-shift",
227+ "content-type", "specific-use", "xlink:actuate",
228+ "xlink:href", "xlink:role", "xlink:show",
229+ "xlink:type"]]
230+ return $ selfClosingTag "graphic" attr
207231blockToJATS opts (Para lst) =
208232 inTagsIndented "p" <$> inlinesToJATS opts lst
209233blockToJATS opts (LineBlock lns) =
@@ -379,8 +403,8 @@ inlineToJATS _ (Link _attr [Str t] ('m':'a':'i':'l':'t':'o':':':email, _))
379403 return $ inTagsSimple "email" $ text (escapeStringForXML email)
380404inlineToJATS opts (Link (ident,_,kvs) txt ('#':src, _)) = do
381405 let attr = [("id", ident) | not (null ident)] ++
382− [("alt", stringify txt),
383− ("rid", src)] ++
406+ [("alt", stringify txt) | not (null txt)] ++
407+ [("rid", src)] ++
384408 [(k,v) | (k,v) <- kvs, k `elem` ["ref-type", "specific-use"]]
385409 contents <- inlinesToJATS opts txt
386410 return $ inTags False "xref" attr contents