git.iko.soy/typeable/pandoc
on master help sign in
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/`).

commita78fd5dbc01f2ead8bf5926e9dfead8a6014382e authorJohn MacFarlane <jgm@berkeley.edu> dateTue 6 Oct 2020, 17:33 (6 years ago) parentd4707ee
1 file changed+6−1
src/Text/Pandoc/Citeproc.hs+6−1
src/Text/Pandoc/Citeproc.hs+6−1
@@ -475,11 +475,16 @@ linkifyVariables ref =
475475 ref{ referenceVariables = M.mapWithKey go $ referenceVariables ref }
476476 where
477477 go "URL" x = tolink "https://" x
478− go "DOI" x = tolink "https://doi.org/" x
478+ go "DOI" x = tolink "https://doi.org/" (fixShortDOI x)
479479 go "ISBN" x = tolink "https://worldcat.org/isbn/" x
480480 go "PMID" x = tolink "https://www.ncbi.nlm.nih.gov/pubmed/" x
481481 go "PMCID" x = tolink "https://www.ncbi.nlm.nih.gov/pmc/articles/" x
482482 go _ x = x
483+ fixShortDOI x = let x' = extractText x
484+ in if "10/" `T.isPrefixOf` x'
485+ then TextVal $ T.drop 3 x'
486+ -- see http://shortdoi.org
487+ else TextVal x'
483488 tolink pref x = let x' = extractText x
484489 x'' = if "://" `T.isInfixOf` x'
485490 then x'