From 85d49ee9366e99e45aa791320b5a8b4436715009 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 1 Sep 2007 02:18:25 +0000 Subject: Combined linebreak and whitespace into a new whitespace parser, to avoid unnecessary reparsing of space characters. git-svn-id: https://pandoc.googlecode.com/svn/trunk@978 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Readers/Markdown.hs') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index a0d6e9968..97291d501 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -625,9 +625,8 @@ table = failIfStrict >> (simpleTable <|> multilineTable) "table" inline = choice [ str , smartPunctuation - , linebreak - , endline , whitespace + , endline , code , charRef , strong @@ -766,11 +765,11 @@ enDash = try $ char '-' >> notFollowedBy (noneOf "0123456789") >> return EnDash emDash = try $ skipSpaces >> oneOfStrings ["---", "--"] >> skipSpaces >> return EmDash -whitespace = (many1 (oneOf spaceChars) >> return Space) "whitespace" - --- hard line break -linebreak = try $ oneOf spaceChars >> many1 (oneOf spaceChars) >> - endline >> return LineBreak +whitespace = do + sps <- many1 (oneOf spaceChars) + if length sps >= 2 + then option Space (endline >> return LineBreak) + else return Space "whitespace" nonEndline = satisfy (/='\n') -- cgit v1.2.3