mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
JATS writer: fix citations with PMID so they validate.
Closes #5481. This includes an update to data/jats.csl.
This commit is contained in:
+2
-4
@@ -64,7 +64,7 @@
|
||||
<if type="book" match="any">
|
||||
<group prefix="{{jats}}<source>{{/jats}}" suffix="{{jats}}</source>{{/jats}}">
|
||||
<text variable="title"/>
|
||||
</group>
|
||||
</group>
|
||||
</if>
|
||||
<else>
|
||||
<group prefix="{{jats}}<article-title>{{/jats}}" suffix="{{jats}}</article-title>{{/jats}}">
|
||||
@@ -90,8 +90,7 @@
|
||||
</choose>
|
||||
<choose>
|
||||
<if match="any" variable="PMID">
|
||||
<group prefix="{{jats}}<ext-link ext-link-type="pmid" {{/jats}}" suffix="{{jats}}</ext-link>{{/jats}}">
|
||||
<text variable="PMID" prefix="{{jats}}xlink:href="http://www.ncbi.nlm.nih.gov/pubmed/{{/jats}}" suffix="{{jats}}" xlink:type="simple">{{/jats}}"/>
|
||||
<group prefix="{{jats}}<pub-id pub-id-type="pmid">{{/jats}}" suffix="{{jats}}</pub-id>{{/jats}}">
|
||||
<text variable="PMID"/>
|
||||
</group>
|
||||
</if>
|
||||
@@ -202,4 +201,3 @@
|
||||
</layout>
|
||||
</bibliography>
|
||||
</style>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import Prelude
|
||||
import Control.Monad.Reader
|
||||
import Data.Char (toLower)
|
||||
import Data.Generics (everywhere, mkT)
|
||||
import Data.List (isSuffixOf, partition)
|
||||
import Data.List (isSuffixOf, partition, isPrefixOf)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Text (Text)
|
||||
import Text.Pandoc.Class (PandocMonad, report)
|
||||
@@ -322,11 +322,15 @@ inlinesToJATS :: PandocMonad m => WriterOptions -> [Inline] -> JATS m Doc
|
||||
inlinesToJATS opts lst = hcat <$> mapM (inlineToJATS opts) (fixCitations lst)
|
||||
where
|
||||
fixCitations [] = []
|
||||
fixCitations (x@(RawInline (Format "jats") "<pub-id pub-id-type=\"doi\">") : xs) =
|
||||
let isRawInline (RawInline{}) = True
|
||||
isRawInline _ = False
|
||||
(ys,zs) = break isRawInline xs
|
||||
in x : Str (stringify ys) : fixCitations zs
|
||||
fixCitations (x:xs) | needsFixing x =
|
||||
x : Str (stringify ys) : fixCitations zs
|
||||
where
|
||||
needsFixing (RawInline (Format "jats") z) =
|
||||
"<pub-id pub-id-type=" `isPrefixOf` z
|
||||
needsFixing _ = False
|
||||
isRawInline (RawInline{}) = True
|
||||
isRawInline _ = False
|
||||
(ys,zs) = break isRawInline xs
|
||||
fixCitations (x:xs) = x : fixCitations xs
|
||||
|
||||
-- | Convert an inline element to JATS.
|
||||
|
||||
Reference in New Issue
Block a user