From 0871a512d7f5cc71f130a7ac56dbe8dfa9d75051 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 26 Nov 2010 12:06:56 -0800 Subject: Split locator and suffix in Biblio rather than Markdown parser. Patch from Nathan Gass. --- src/Text/Pandoc/Readers/Markdown.hs | 38 ++----------------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2d3ad1199..1b3900798 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, isDigit ) +import Data.Char ( isAlphaNum ) import Data.Maybe import Text.Pandoc.Definition import Text.Pandoc.Shared @@ -1319,23 +1319,12 @@ spnl = try $ do skipSpaces notFollowedBy (char '\n') -blankSpace :: GenParser Char st () -blankSpace = try $ do - res <- many1 $ oneOf " \t\n" - guard $ length res > 0 - guard $ length (filter (=='\n') res) <= 1 - -noneOfUnlessEscaped :: [Char] -> GenParser Char st Char -noneOfUnlessEscaped cs = - try (char '\\' >> oneOf cs) <|> noneOf cs - textualCite :: GenParser Char ParserState [Citation] textualCite = try $ do (_, key) <- citeKey let first = Citation{ citationId = key , citationPrefix = [] , citationSuffix = [] - , citationLocator = "" , citationMode = AuthorInText , citationNoteNum = 0 , citationHash = 0 @@ -1349,12 +1338,11 @@ bareloc :: Citation -> GenParser Char ParserState [Citation] bareloc c = try $ do spnl char '[' - loc <- locator suff <- suffix rest <- option [] $ try $ char ';' >> citeList spnl char ']' - return $ c{ citationLocator = loc, citationSuffix = suff } : rest + return $ c{ citationSuffix = suff } : rest normalCite :: GenParser Char ParserState [Citation] normalCite = try $ do @@ -1376,26 +1364,6 @@ citeKey = try $ do guard $ key `elem` stateCitations st return (suppress_author, key) -locator :: GenParser Char st String -locator = try $ do - spnl - w <- many1 (noneOf " \t\n;,]") - ws <- many (locatorWord <|> locatorComma) - return $ unwords $ w:ws - -locatorWord :: GenParser Char st String -locatorWord = try $ do - spnl - wd <- many1 $ noneOfUnlessEscaped "];, \t\n" - guard $ any isDigit wd - return wd - -locatorComma :: GenParser Char st String -locatorComma = try $ do - char ',' - lookAhead $ locatorWord - return "," - suffix :: GenParser Char ParserState [Inline] suffix = try $ do spnl @@ -1412,12 +1380,10 @@ citation :: GenParser Char ParserState Citation citation = try $ do pref <- prefix (suppress_author, key) <- citeKey - loc <- option "" $ try $ blankSpace >> locator suff <- suffix return $ Citation{ citationId = key , citationPrefix = pref , citationSuffix = suff - , citationLocator = loc , citationMode = if suppress_author then SuppressAuthor else NormalCitation -- cgit v1.2.3