aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs16
-rw-r--r--tests/markdown-citations.plain14
2 files changed, 15 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index eb9646df2..0d0e850bc 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1332,9 +1332,9 @@ textualCite = try $ do
spnl
char '['
spnl
- bareloc <- option "" locator
+ bareloc <- option "" $ notFollowedBy (oneOf "-@") >> locator
rest <- many $ try $ do
- char ';'
+ optional $ char ';'
spnl
citation
spnl
@@ -1366,10 +1366,10 @@ locator = try $ do
(char '\n' >> notFollowedBy blankline >> return ' ')
prefix :: GenParser Char st String
-prefix = try $ liftM removeLeadingTrailingSpace $
- many $ (char '\\' >> anyChar) <|> noneOf "@]\n" <|>
- (char '-' >> notFollowedBy (char '@') >> return '-') <|>
- (char '\n' >> notFollowedBy blankline >> return ' ')
+prefix = liftM removeLeadingTrailingSpace $
+ many $ (char '\\' >> anyChar) <|> noneOf "-@]\n" <|>
+ (try $ char '-' >> notFollowedBy (char '@') >> return '-') <|>
+ (try $ char '\n' >> notFollowedBy blankline >> return ' ')
citeList :: GenParser Char st [Citation]
citeList = try $ do
@@ -1387,10 +1387,10 @@ citeList = try $ do
citation :: GenParser Char st Citation
citation = try $ do
- suppress_auth <- option False (char '-' >> return True)
pref <- prefix
+ suppress_auth <- option False (char '-' >> return True)
key <- citeKey
- loc <- locator
+ loc <- option "" locator
return $ Citation{ citationId = key
, citationPrefix = pref
, citationLocator = loc
diff --git a/tests/markdown-citations.plain b/tests/markdown-citations.plain
index 35218d954..b809842be 100644
--- a/tests/markdown-citations.plain
+++ b/tests/markdown-citations.plain
@@ -5,8 +5,8 @@ Pandoc with citeproc-hs
@nonexistent
-Doe (2005) says blah. Doe (2005, 30) says blah. Doe (2005; 2006,
-30; see also Doe and Roe 2007) says blah.
+Doe (2005) says blah. Doe (2005, 30) says blah. Doe
+(2005; 2006, 30; see also Doe and Roe 2007) says blah.
In a note.[^1] A citation group
(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,
ed. Sam Smith. Oxford: Oxford University Press.
[^1]:
- A citation without locators [Doe and Roe (2007)].
+ A citation without locators (Doe and Roe 2007).
[^2]:
- Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe
- 2005).
+ Some citations
+ (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005).
[^3]:
- Like a citation without author: (2005), and now Doe with a
- locator (2006, 44).
+ Like a citation without author: (2005), and now Doe with a locator
+ (2006, 44).