aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-04-19 16:49:34 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-04-19 16:49:34 -0700
commit5b5813c30b458d3eee96e8e5be5c44451b2037b8 (patch)
tree3dda9f54b39c96c37e354fecf9740c1442acf964 /src
parent1a69896d8f2c676aaf8563e1a7b2ba5870597f54 (diff)
parente83968412e308bfd34c7ba4d1ad01592878fc95a (diff)
downloadpandoc-5b5813c30b458d3eee96e8e5be5c44451b2037b8.tar.gz
Merge pull request #2090 from lierdakil/issue2083
Fix for #2083 (citation suffix clashes with links and footnotes)
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 656e4ec66..b54b947b4 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1887,8 +1887,20 @@ textualCite = try $ do
return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw) . (first:))
<$> rest
Nothing ->
- (do (cs, raw) <- withRaw $ bareloc first
- return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw)) <$> cs)
+ (do
+ (cs, raw) <- withRaw $ bareloc first
+ let (spaces',raw') = span isSpace raw
+ spc | null spaces' = mempty
+ | otherwise = B.space
+ lab <- parseFromString (mconcat <$> many inline) $ dropBrackets raw'
+ fallback <- referenceLink B.link (lab,raw')
+ return $ do
+ fallback' <- fallback
+ cs' <- cs
+ return $
+ case B.toList fallback' of
+ Link{}:_ -> B.cite [first] (B.str $ '@':key) <> spc <> fallback'
+ _ -> B.cite cs' (B.text $ '@':key ++ " " ++ raw))
<|> return (do st <- askF
return $ case M.lookup key (stateExamples st) of
Just n -> B.str (show n)
@@ -1898,10 +1910,12 @@ bareloc :: Citation -> MarkdownParser (F [Citation])
bareloc c = try $ do
spnl
char '['
+ notFollowedBy $ char '^'
suff <- suffix
rest <- option (return []) $ try $ char ';' >> citeList
spnl
char ']'
+ notFollowedBy $ oneOf "[("
return $ do
suff' <- suff
rest' <- rest