@@ -182,6 +182,7 @@ parseBlock (Elem e) =
182 "sec" -> gets jatsSectionLevel >>= sect . (+1)
182 "sec" -> gets jatsSectionLevel >>= sect . (+1)
183 "title" -> return mempty
183 "title" -> return mempty
184 "title-group" -> checkInMeta getTitle
184 "title-group" -> checkInMeta getTitle
185+ "contrib-group" -> checkInMeta getAuthors
185 "graphic" -> para <$> getGraphic e
186 "graphic" -> para <$> getGraphic e
186 "journal-meta" -> metaBlock
187 "journal-meta" -> metaBlock
187 "article-meta" -> metaBlock
188 "article-meta" -> metaBlock
@@ -239,7 +240,28 @@ parseBlock (Elem e) =
239 Just s -> (text ": " <>) <$>
240 Just s -> (text ": " <>) <$>
240 getInlines s
241 getInlines s
241 Nothing -> return mempty
242 Nothing -> return mempty
242− addMeta "title" (tit <> subtit)
243+ when (tit /= mempty) $ addMeta "title" tit
244+ when (subtit /= mempty) $ addMeta "subtitle" subtit
246+ getAuthors :: PandocMonad m => JATS m ()
248+ authors <- mapM getContrib $ filterChildren
249+ (\x -> named "contrib" x &&
250+ attrValue "contrib-type" x == "author") e
251+ unless (null authors) $ addMeta "author" authors
253+ getContrib :: PandocMonad m => Element -> JATS m Inlines
255+ given <- maybe (return mempty) getInlines
256+ $ filterElement (named "given-names") x
257+ family <- maybe (return mempty) getInlines
258+ $ filterElement (named "surname") x
259+ if given == mempty && family == mempty
261+ else if given == mempty || family == mempty
262+ then return $ given <> family
263+ else return $ given <> space <> family
264+ -- TODO institute, etc.
244 parseTable = do
266 parseTable = do
245 let isCaption x = named "title" x || named "caption" x
267 let isCaption x = named "title" x || named "caption" x
@@ -345,19 +367,19 @@ parseRef e = do
345 let refPages = refFirstPage <> (if refLastPage == mempty
367 let refPages = refFirstPage <> (if refLastPage == mempty
346 then mempty
368 then mempty
347 else text "\x2013" <> refLastPage)
369 else text "\x2013" <> refLastPage)
348− let personGroups' = filterElements (named "person-group") c
370+ let personGroups' = filterChildren (named "person-group") c
349 let getName nm = do
371 let getName nm = do
350 given <- maybe (return mempty) getInlines
372 given <- maybe (return mempty) getInlines
351− $ filterElement (named "given-names") nm
373+ $ filterChild (named "given-names") nm
352 family <- maybe (return mempty) getInlines
374 family <- maybe (return mempty) getInlines
353− $ filterElement (named "surname") nm
375+ $ filterChild (named "surname") nm
354 return $ toMetaValue $ Map.fromList [
376 return $ toMetaValue $ Map.fromList [
355 ("given", given)
377 ("given", given)
356 , ("family", family)
378 , ("family", family)
358 personGroups <- mapM (\pg ->
380 personGroups <- mapM (\pg ->
359 do names <- mapM getName
381 do names <- mapM getName
360− (filterElements (named "name") pg)
382+ (filterChildren (named "name") pg)
361 return (attrValue "person-group-type" pg,
383 return (attrValue "person-group-type" pg,
362 toMetaValue names))
384 toMetaValue names))
363 personGroups'
385 personGroups'