JATS reader: strip 'ref-' from ref id in constructing CSL id.

This allows better round-tripping, because the JATS
writer adds the `ref-` prefix to the citation id to get
the ref element's id.
This commit is contained in:
John MacFarlane 2022-03-28 18:50:03 -07:00
parent 51c8b059e1
commit 807a574e9d

View file

@ -460,7 +460,10 @@ parseRef e = do
x -> x) :) .
catMaybes <$> mapM (refElement c) (elChildren c)
Nothing -> pure [] -- TODO handle mixed-citation
return $ Map.fromList (("id", toMetaValue $ attrValue "id" e) : refVariables)
-- allows round-tripping, since JATS writer puts ref- in front of citation ids:
let stripPref t = fromMaybe t $ T.stripPrefix "ref-" t
return $ Map.fromList (("id", toMetaValue $ stripPref $ attrValue "id" e)
: refVariables)
textContent :: Element -> Text
textContent = strContent