aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-11-26 22:09:17 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-11-26 22:34:53 -0800
commit0ca84f0d381639ca996eb037c9c4057b2de4ed2f (patch)
tree109369f7b9c4241392a2d5f7be73e1bee489892c /src/Text/Pandoc/Readers
parent0871a512d7f5cc71f130a7ac56dbe8dfa9d75051 (diff)
downloadpandoc-0ca84f0d381639ca996eb037c9c4057b2de4ed2f.tar.gz
Markdown suffix parser fix.
If suffix doesn't begin with punctuation, include opening comma and space in result. Previously, @item [only a suffix] would result in something like Doe (2002only a suffix) because there was no opening delimiter.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 1b3900798..d39050243 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -34,7 +34,7 @@ module Text.Pandoc.Readers.Markdown (
import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate )
import qualified Data.Map as M
import Data.Ord ( comparing )
-import Data.Char ( isAlphaNum )
+import Data.Char ( isAlphaNum, isPunctuation )
import Data.Maybe
import Text.Pandoc.Definition
import Text.Pandoc.Shared
@@ -1367,7 +1367,12 @@ citeKey = try $ do
suffix :: GenParser Char ParserState [Inline]
suffix = try $ do
spnl
- liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline
+ res <- many $ notFollowedBy (oneOf ";]") >> inline
+ return $ case res of
+ [] -> []
+ (Str (y:_) : _) | isPunctuation y
+ -> res
+ _ -> Str "," : Space : res
prefix :: GenParser Char ParserState [Inline]
prefix = liftM normalizeSpaces $