diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-06 19:20:00 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-06 19:20:00 -0700 |
commit | a27a0b5419d8abdb374fac7cddc6f9ce128c0f96 (patch) | |
tree | 95fdd5e1e05aa783c5b018a0c63fc34da6beca9f /src | |
parent | a78fd5dbc01f2ead8bf5926e9dfead8a6014382e (diff) | |
download | pandoc-a27a0b5419d8abdb374fac7cddc6f9ce128c0f96.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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@(_:_) = |