aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-11-11 22:35:04 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-11-11 22:35:04 -0800
commit5c6dc5767df68ae739138ae38f2baf75949ef3e6 (patch)
tree30ee5968c74097ab7c6cc5a82d0e35e1fb5d3d3b /src
parent1bfd8110affb394d648911a33c941f5d44e2422f (diff)
downloadpandoc-5c6dc5767df68ae739138ae38f2baf75949ef3e6.tar.gz
Biblio: Use a Map for the lookup table.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Biblio.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
index c334d89ce..bca24d815 100644
--- a/src/Text/Pandoc/Biblio.hs
+++ b/src/Text/Pandoc/Biblio.hs
@@ -32,6 +32,7 @@ module Text.Pandoc.Biblio ( processBiblio ) where
import Control.Monad ( when )
import Data.List
import Data.Unique
+import qualified Data.Map as M
import Text.CSL hiding ( Cite(..), Citation(..) )
import qualified Text.CSL as CSL ( Cite(..) )
import Text.Pandoc.Definition
@@ -52,19 +53,19 @@ processBiblio cf r p
needNt = cits \\ concat ncits
in (,) needNt $ getNoteCitations needNt p'
result = citeproc csl r (setNearNote csl $ map (map toCslCite) grps)
- cits_map = zip grps (citations result)
+ cits_map = M.fromList $ zip grps (citations result)
biblioList = map (renderPandoc' csl) (bibliography result)
Pandoc m b = processWith (procInlines $ processCite csl cits_map) p'
return . generateNotes nts . Pandoc m $ b ++ biblioList
-- | Substitute 'Cite' elements with formatted citations.
-processCite :: Style -> [([Citation],[FormattedOutput])] -> [Inline] -> [Inline]
+processCite :: Style -> M.Map [Citation] [FormattedOutput] -> [Inline] -> [Inline]
processCite _ _ [] = []
processCite s cs (i:is)
| Cite t _ <- i = process t ++ processCite s cs is
| otherwise = i : processCite s cs is
where
- process t = case lookup t cs of
+ process t = case M.lookup t cs of
Just x -> if isTextualCitation t && x /= []
then renderPandoc s [head x] ++ [Space] ++
[Cite t $ renderPandoc s $ tail x]