git.iko.soy/typeable/pandoc
on master help sign in
Updated for changes in Citaiton type.
ce9fc2aJohn MacFarlane
src/Text/Pandoc/Biblio.hs+20−9
@@ -99,8 +99,8 @@ getNoteCitations needNote
99 in queryWith getCitation . getCits
99 in queryWith getCitation . getCits
100
100
101setHash :: Citation -> IO Citation
101setHash :: Citation -> IO Citation
102−setHash (Citation i p l cm nn _)
102+setHash (Citation i p s l cm nn _)
103− = hashUnique `fmap` newUnique >>= return . Citation i p l cm nn
103+ = hashUnique `fmap` newUnique >>= return . Citation i p s l cm nn
104
104
105generateNotes :: [Inline] -> Pandoc -> Pandoc
105generateNotes :: [Inline] -> Pandoc -> Pandoc
106generateNotes needNote = processWith (mvCiteInNote needNote)
106generateNotes needNote = processWith (mvCiteInNote needNote)
@@ -150,19 +150,30 @@ setCiteNoteNum _ _ = []
150setCitationNoteNum :: Int -> [Citation] -> [Citation]
150setCitationNoteNum :: Int -> [Citation] -> [Citation]
151setCitationNoteNum i = map $ \c -> c { citationNoteNum = i}
151setCitationNoteNum i = map $ \c -> c { citationNoteNum = i}
152
152
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+
153toCslCite :: Citation -> CSL.Cite
163toCslCite :: Citation -> CSL.Cite
154−toCslCite (Citation i p l cm nn h)
164+toCslCite c
155− = let (la,lo) = parseLocator l
165+ = let (la,lo) = parseLocator $ citationLocator c
156− citMode = case cm of
166+ citMode = case citationMode c of
157 AuthorInText -> (True, False)
167 AuthorInText -> (True, False)
158 SuppressAuthor -> (False,True )
168 SuppressAuthor -> (False,True )
159 NormalCitation -> (False,False)
169 NormalCitation -> (False,False)
160− in emptyCite { CSL.citeId = i
170+ in emptyCite { CSL.citeId = citationId c
161− , CSL.citePrefix = p
171+ , CSL.citePrefix = stringify $ citationPrefix c
172+ , CSL.citeSuffix = stringify $ citationSuffix c
162 , CSL.citeLabel = la
173 , CSL.citeLabel = la
163 , CSL.citeLocator = lo
174 , CSL.citeLocator = lo
164− , CSL.citeNoteNumber = show nn
175+ , CSL.citeNoteNumber = show $ citationNoteNum c
165 , CSL.authorInText = fst citMode
176 , CSL.authorInText = fst citMode
166 , CSL.suppressAuthor = snd citMode
177 , CSL.suppressAuthor = snd citMode
167− , CSL.citeHash = h
178+ , CSL.citeHash = citationHash c
168 }
179 }
src/Text/Pandoc/Readers/Markdown.hs+4−3
@@ -1322,7 +1322,8 @@ textualCite = try $ do
1322 unless (key `elem` stateCitations st) $
1322 unless (key `elem` stateCitations st) $
1323 fail "not a citation"
1323 fail "not a citation"
1324 let first = Citation{ citationId = key
1324 let first = Citation{ citationId = key
1325− , citationPrefix = ""
1325+ , citationPrefix = []
1326+ , citationSuffix = []
1326 , citationLocator = ""
1327 , citationLocator = ""
1327 , citationMode = AuthorInText
1328 , citationMode = AuthorInText
1328 , citationNoteNum = 0
1329 , citationNoteNum = 0
@@ -1361,7 +1362,6 @@ locator :: GenParser Char st String
1361locator = try $ do
1362locator = try $ do
1362 optional $ char ','
1363 optional $ char ','
1363 spnl
1364 spnl
1364− -- TODO should eventually be list of inlines
1365 many1 $ (char '\\' >> oneOf "];\n") <|> noneOf "];\n" <|>
1365 many1 $ (char '\\' >> oneOf "];\n") <|> noneOf "];\n" <|>
1366 (char '\n' >> notFollowedBy blankline >> return ' ')
1366 (char '\n' >> notFollowedBy blankline >> return ' ')
1367
1367
@@ -1392,7 +1392,8 @@ citation = try $ do
1392 key <- citeKey
1392 key <- citeKey
1393 loc <- option "" locator
1393 loc <- option "" locator
1394 return $ Citation{ citationId = key
1394 return $ Citation{ citationId = key
1395− , citationPrefix = pref
1395+ , citationPrefix = [Str pref]
1396+ , citationSuffix = []
1396 , citationLocator = loc
1397 , citationLocator = loc
1397 , citationMode = if suppress_auth
1398 , citationMode = if suppress_auth
1398 then SuppressAuthor
1399 then SuppressAuthor