aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-10-06 17:33:25 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-10-06 17:33:25 -0700
commita78fd5dbc01f2ead8bf5926e9dfead8a6014382e (patch)
treeea255534a1cf1e37fd4fc85f09becfe23d3b0024 /src/Text/Pandoc
parentd4707ee8bd3bbfabd39116915ac3441eeab0fe93 (diff)
downloadpandoc-a78fd5dbc01f2ead8bf5926e9dfead8a6014382e.tar.gz
Fix URL for "short DOIs" in citations. See #6723.
Short DOIs begin 10/abcd and should be links to `https://doi.org/abcd` (omitting the `10/`).
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Citeproc.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
index 740e39f5e..732c60f29 100644
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -475,11 +475,16 @@ linkifyVariables ref =
ref{ referenceVariables = M.mapWithKey go $ referenceVariables ref }
where
go "URL" x = tolink "https://" x
- go "DOI" x = tolink "https://doi.org/" x
+ go "DOI" x = tolink "https://doi.org/" (fixShortDOI x)
go "ISBN" x = tolink "https://worldcat.org/isbn/" x
go "PMID" x = tolink "https://www.ncbi.nlm.nih.gov/pubmed/" x
go "PMCID" x = tolink "https://www.ncbi.nlm.nih.gov/pmc/articles/" x
go _ x = x
+ fixShortDOI x = let x' = extractText x
+ in if "10/" `T.isPrefixOf` x'
+ then TextVal $ T.drop 3 x'
+ -- see http://shortdoi.org
+ else TextVal x'
tolink pref x = let x' = extractText x
x'' = if "://" `T.isInfixOf` x'
then x'