git.iko.soy/typeable/pandoc
on master help sign in
Repairs to citation parser + citation test suite.
1fa2973John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+8−8
@@ -1332,9 +1332,9 @@ textualCite = try $ do
1332 spnl
1332 spnl
1333 char '['
1333 char '['
1334 spnl
1334 spnl
1335− bareloc <- option "" locator
1335+ bareloc <- option "" $ notFollowedBy (oneOf "-@") >> locator
1336 rest <- many $ try $ do
1336 rest <- many $ try $ do
1337− char ';'
1337+ optional $ char ';'
1338 spnl
1338 spnl
1339 citation
1339 citation
1340 spnl
1340 spnl
@@ -1366,10 +1366,10 @@ locator = try $ do
1366 (char '\n' >> notFollowedBy blankline >> return ' ')
1366 (char '\n' >> notFollowedBy blankline >> return ' ')
1367
1367
1368prefix :: GenParser Char st String
1368prefix :: GenParser Char st String
1369−prefix = try $ liftM removeLeadingTrailingSpace $
1369+prefix = liftM removeLeadingTrailingSpace $
1370− many $ (char '\\' >> anyChar) <|> noneOf "@]\n" <|>
1370+ many $ (char '\\' >> anyChar) <|> noneOf "-@]\n" <|>
1371− (char '-' >> notFollowedBy (char '@') >> return '-') <|>
1371+ (try $ char '-' >> notFollowedBy (char '@') >> return '-') <|>
1372− (char '\n' >> notFollowedBy blankline >> return ' ')
1372+ (try $ char '\n' >> notFollowedBy blankline >> return ' ')
1373
1373
1374citeList :: GenParser Char st [Citation]
1374citeList :: GenParser Char st [Citation]
1375citeList = try $ do
1375citeList = try $ do
@@ -1387,10 +1387,10 @@ citeList = try $ do
1387
1387
1388citation :: GenParser Char st Citation
1388citation :: GenParser Char st Citation
1389citation = try $ do
1389citation = try $ do
1390− suppress_auth <- option False (char '-' >> return True)
1391 pref <- prefix
1390 pref <- prefix
1391+ suppress_auth <- option False (char '-' >> return True)
1392 key <- citeKey
1392 key <- citeKey
1393− loc <- locator
1393+ loc <- option "" locator
1394 return $ Citation{ citationId = key
1394 return $ Citation{ citationId = key
1395 , citationPrefix = pref
1395 , citationPrefix = pref
1396 , citationLocator = loc
1396 , citationLocator = loc
tests/markdown-citations.plain+7−7
@@ -5,8 +5,8 @@ Pandoc with citeproc-hs
5
5
6@nonexistent
6@nonexistent
7
7
8−Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005; 2006,
8+Doe (2005) says blah. Doe (2005, 30) says blah. Doe
9−30; see also Doe and Roe 2007) says blah.
9+(2005; 2006, 30; see also Doe and Roe 2007) says blah.
10
10
11In a note.[^1] A citation group
11In a note.[^1] A citation group
12(see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one
12(see Doe 2005, 34-35; also Doe and Roe 2007, chap. 3). Another one
@@ -26,12 +26,12 @@ Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In Third Book,
26ed. Sam Smith. Oxford: Oxford University Press.
26ed. Sam Smith. Oxford: Oxford University Press.
27
27
28[^1]:
28[^1]:
29− A citation without locators [Doe and Roe (2007)].
29+ A citation without locators (Doe and Roe 2007).
30
30
31[^2]:
31[^2]:
32+ Some citations
32− Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe
33+ (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005).
33− 2005).
34
34
35[^3]:
35[^3]:
36− Like a citation without author: (2005), and now Doe with a
36+ Like a citation without author: (2005), and now Doe with a locator
37− locator (2006, 44).
37+ (2006, 44).