diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-03-12 11:57:31 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-03-12 11:58:52 -0800 |
commit | 894ed8ebb01ce11cbcc6afc13d00d6ac1dd05ed0 (patch) | |
tree | f0d16c599e3f1d8fc70e3f4e203c04504f38b1b5 | |
parent | 92ffd374754e28939a855fe84fb5455cb91383fa (diff) | |
download | pandoc-894ed8ebb01ce11cbcc6afc13d00d6ac1dd05ed0.tar.gz |
Citeproc: apply fixLinks correctly.
This is code that incorporates a prefix like `https://doi.org/`
into a following link when appropriate. But it didn't work because
we were walking with a `[Inline] -> [Inline]` function on an `Inlines`.
Changed the point of application of `fixLink` to resolve the issue.
Closes #7130.
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 38e992ba1..af302f782 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -49,7 +49,6 @@ import Data.Text (Text) import qualified Data.Text as T import System.FilePath (takeExtension) import Safe (lastMay, initSafe) --- import Debug.Trace as Trace (trace, traceShowId) processCitations :: PandocMonad m => Pandoc -> m Pandoc @@ -91,11 +90,12 @@ processCitations (Pandoc meta bs) = do _ -> id) $ [] let bibs = mconcat $ map (\(ident, out) -> B.divWith ("ref-" <> ident,["csl-entry"],[]) . B.para . - walk (convertQuotes locale) . insertSpace $ out) + walk (convertQuotes locale) . + insertSpace $ out) (resultBibliography result) let moveNotes = maybe True truish $ lookupMeta "notes-after-punctuation" meta - let cits = map (walk fixLinks . walk (convertQuotes locale)) $ + let cits = map (walk (convertQuotes locale)) $ resultCitations result let fixQuotes = case localePunctuationInQuote locale of @@ -294,7 +294,7 @@ insertResolvedCitations (Cite cs ils) = do [] -> return (Cite cs ils) (x:xs) -> do put xs - return $ Cite cs (B.toList x) + return $ Cite cs (walk fixLinks $ B.toList x) insertResolvedCitations x = return x getCitations :: Locale @@ -431,7 +431,7 @@ 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 + | u2 == t <> u1 = Link attr [Str (t <> u1)] (u2,tit) : fixLinks xs fixLinks (x:xs) = x : fixLinks xs fixLinks [] = [] |