From 87d6d0d069fc24724ee55cf54711c8abe2f2d072 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 15 Nov 2007 17:29:24 +0000 Subject: Fixed logic in markdown smart quote parsing: + Added some needed 'try' statements. + Unicode right single-quote can double as apostrophe, so treat it as a quote-end only when not followed by an alphanumeric character. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1077 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 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 080e2525c..e50180a63 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -760,21 +760,24 @@ failIfInQuoteContext context = do singleQuoteStart = do failIfInQuoteContext InSingleQuote char '\8216' <|> - do char '\'' - notFollowedBy (oneOf ")!],.;:-? \t\n") - notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >> - satisfy (not . isAlphaNum))) -- possess/contraction - return '\'' - -singleQuoteEnd = char '\8217' <|> - (char '\'' >> notFollowedBy alphaNum >> return '\'') + (try $ do char '\'' + notFollowedBy (oneOf ")!],.;:-? \t\n") + notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >> + satisfy (not . isAlphaNum))) + -- possess/contraction + return '\'') + +singleQuoteEnd = try $ do + char '\8217' <|> char '\'' + notFollowedBy alphaNum + return '\'' doubleQuoteStart = do failIfInQuoteContext InDoubleQuote char '\8220' <|> - do char '"' - notFollowedBy (oneOf " \t\n") - return '"' + (try $ do char '"' + notFollowedBy (oneOf " \t\n") + return '"') doubleQuoteEnd = char '\8221' <|> char '"' -- cgit v1.2.3