From a27a0b5419d8abdb374fac7cddc6f9ce128c0f96 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 6 Oct 2020 19:20:00 -0700 Subject: Incorporate `https://doi.org/` prefix added by CSL style... ...into linked DOI, and similarly for other URLs linked in the bibliography. We want to avoid having a URL in which only the latter part is linked. Closes #6723. --- src/Text/Pandoc/Citeproc.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 732c60f29..528be6cd7 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -164,7 +164,9 @@ processCitations (Pandoc meta bs) = do walk (fixQuotes . mvPunct moveNotes locale) $ walk deNote $ evalState (walkM insertResolvedCitations $ Pandoc meta' bs) $ cits - return $ Pandoc meta'' $ insertRefs refkvs classes meta'' (B.toList bibs) bs' + return $ Pandoc meta'' + $ insertRefs refkvs classes meta'' + (walk fixLinks $ B.toList bibs) bs' -- If we have a span.csl-left-margin followed by span.csl-right-inline, -- we insert a space. This ensures that they will be separated by a space, @@ -376,6 +378,15 @@ mvPunct moveNotes locale (Cite cs ils : Str "." : ys) mvPunct moveNotes locale (x:xs) = x : mvPunct moveNotes locale xs mvPunct _ _ [] = [] +-- move https://doi.org etc. prefix inside link text (#6723): +fixLinks :: [Inline] -> [Inline] +fixLinks (Str t : Link attr [Str u1] (u2,tit) : xs) + | t <> u1 == u2 + = Link attr [Str (t <> u1)] (u2,tit) : fixLinks xs +fixLinks (x:xs) = x : fixLinks xs +fixLinks [] = [] + + endWithPunct :: Bool -> [Inline] -> Bool endWithPunct _ [] = False endWithPunct onlyFinal xs@(_:_) = -- cgit v1.2.3