git.iko.soy/typeable/pandoc
on master help sign in
Updated for changes in Citaiton type.

citationPrefix now [Inline] rather than String; citationSuffix added. This change presupposes no changes in citeproc-hs. It passes a string for these values to citeproc-hs. Eventually, citeproc-hs should use an [Inline] for these as well.

commitce9fc2a37d51e65bbfb25eed01cd400e183fb8d9 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 16 Nov 2010, 20:31 (16 years ago) parent55e9916
2 files changed+24−12
src/Text/Pandoc/Biblio.hs+20−9 src/Text/Pandoc/Readers/Markdown.hs+4−3
src/Text/Pandoc/Biblio.hs+20−9
@@ -99,8 +99,8 @@ getNoteCitations needNote
9999 in queryWith getCitation . getCits
100100
101101setHash :: Citation -> IO Citation
102−setHash (Citation i p l cm nn _)
103− = hashUnique `fmap` newUnique >>= return . Citation i p l cm nn
102+setHash (Citation i p s l cm nn _)
103+ = hashUnique `fmap` newUnique >>= return . Citation i p s l cm nn
104104
105105generateNotes :: [Inline] -> Pandoc -> Pandoc
106106generateNotes needNote = processWith (mvCiteInNote needNote)
@@ -150,19 +150,30 @@ setCiteNoteNum _ _ = []
150150setCitationNoteNum :: Int -> [Citation] -> [Citation]
151151setCitationNoteNum i = map $ \c -> c { citationNoteNum = i}
152152
153+-- a temporary function to tide us over until citeproc is
154+-- changed to use Inline lists for prefixes and suffixes...
155+stringify :: [Inline] -> String
156+stringify = queryWith go
157+ where go :: Inline -> [Char]
158+ go Space = " "
159+ go (Str x) = x
160+ go (Code x) = x
161+ go _ = ""
162+
153163toCslCite :: Citation -> CSL.Cite
154−toCslCite (Citation i p l cm nn h)
155− = let (la,lo) = parseLocator l
156− citMode = case cm of
164+toCslCite c
165+ = let (la,lo) = parseLocator $ citationLocator c
166+ citMode = case citationMode c of
157167 AuthorInText -> (True, False)
158168 SuppressAuthor -> (False,True )
159169 NormalCitation -> (False,False)
160− in emptyCite { CSL.citeId = i
161− , CSL.citePrefix = p
170+ in emptyCite { CSL.citeId = citationId c
171+ , CSL.citePrefix = stringify $ citationPrefix c
172+ , CSL.citeSuffix = stringify $ citationSuffix c
162173 , CSL.citeLabel = la
163174 , CSL.citeLocator = lo
164− , CSL.citeNoteNumber = show nn
175+ , CSL.citeNoteNumber = show $ citationNoteNum c
165176 , CSL.authorInText = fst citMode
166177 , CSL.suppressAuthor = snd citMode
167− , CSL.citeHash = h
178+ , CSL.citeHash = citationHash c
168179 }
src/Text/Pandoc/Readers/Markdown.hs+4−3
@@ -1322,7 +1322,8 @@ textualCite = try $ do
13221322 unless (key `elem` stateCitations st) $
13231323 fail "not a citation"
13241324 let first = Citation{ citationId = key
1325− , citationPrefix = ""
1325+ , citationPrefix = []
1326+ , citationSuffix = []
13261327 , citationLocator = ""
13271328 , citationMode = AuthorInText
13281329 , citationNoteNum = 0
@@ -1361,7 +1362,6 @@ locator :: GenParser Char st String
13611362locator = try $ do
13621363 optional $ char ','
13631364 spnl
1364− -- TODO should eventually be list of inlines
13651365 many1 $ (char '\\' >> oneOf "];\n") <|> noneOf "];\n" <|>
13661366 (char '\n' >> notFollowedBy blankline >> return ' ')
13671367
@@ -1392,7 +1392,8 @@ citation = try $ do
13921392 key <- citeKey
13931393 loc <- option "" locator
13941394 return $ Citation{ citationId = key
1395− , citationPrefix = pref
1395+ , citationPrefix = [Str pref]
1396+ , citationSuffix = []
13961397 , citationLocator = loc
13971398 , citationMode = if suppress_auth
13981399 then SuppressAuthor