@@ -105,8 +105,9 @@ module Text.Pandoc.Parsing ( take1WhileP,
105 singleQuoteEnd,
105 singleQuoteEnd,
106 doubleQuoteStart,
106 doubleQuoteStart,
107 doubleQuoteEnd,
107 doubleQuoteEnd,
109 apostrophe,
108 apostrophe,
@@ -1398,10 +1399,7 @@ smartPunctuation :: (HasReaderOptions st, HasLastStrPosition st, HasQuoteContext
1398 -> ParserT s st m Inlines
1399 -> ParserT s st m Inlines
1399smartPunctuation inlineParser = do
1400smartPunctuation inlineParser = do
1400 guardEnabled Ext_smart
1401 guardEnabled Ext_smart
1401− choice [ quoted inlineParser, apostrophe, dash, ellipses ]
1402+ choice [ quoted inlineParser, apostrophe, doubleCloseQuote, dash, ellipses ]
1403−apostrophe :: Stream s m Char => ParserT s st m Inlines
1404−apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
1406quoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
1404quoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
1407 => ParserT s st m Inlines
1405 => ParserT s st m Inlines
@@ -1411,16 +1409,22 @@ quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
1411singleQuoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
1409singleQuoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
1412 => ParserT s st m Inlines
1410 => ParserT s st m Inlines
1413 -> ParserT s st m Inlines
1411 -> ParserT s st m Inlines
1414−singleQuoted inlineParser = try $ B.singleQuoted . mconcat
1412+singleQuoted inlineParser = do
1415− <$ singleQuoteStart
1413+ singleQuoteStart
1414+ (B.singleQuoted . mconcat <$>
1416− <*> withQuoteContext InSingleQuote (many1Till inlineParser singleQuoteEnd)
1416+ (withQuoteContext InSingleQuote (many1Till inlineParser singleQuoteEnd)))
1417−
1417+ <|> pure "\8217"
1418−doubleQuoted :: (HasQuoteContext st m, Stream s m Char)
1419+doubleQuoted :: (HasQuoteContext st m, HasLastStrPosition st, Stream s m Char)
1419 => ParserT s st m Inlines
1420 => ParserT s st m Inlines
1420 -> ParserT s st m Inlines
1421 -> ParserT s st m Inlines
1421−doubleQuoted inlineParser = try $ B.doubleQuoted . mconcat
1422+doubleQuoted inlineParser = do
1422− <$ doubleQuoteStart
1423+ doubleQuoteStart
1424+ (B.doubleQuoted . mconcat <$>
1423− <*> withQuoteContext InDoubleQuote (manyTill inlineParser doubleQuoteEnd)
1426+ (withQuoteContext InDoubleQuote (manyTill inlineParser doubleQuoteEnd)))
1427+ <|> pure (B.str "\8220")
1425failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t)
1429failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t)
1426 => QuoteContext
1430 => QuoteContext
@@ -1443,7 +1447,7 @@ singleQuoteStart = do
1443 guard =<< notAfterString
1447 guard =<< notAfterString
1444 try $ do
1448 try $ do
1445 charOrRef "'\8216\145"
1449 charOrRef "'\8216\145"
1446− notFollowedBy (oneOf [' ', '\t', '\n'])
1450+ notFollowedBy (satisfy isSpaceChar)
1448singleQuoteEnd :: Stream s m Char
1452singleQuoteEnd :: Stream s m Char
1449 => ParserT s st m ()
1453 => ParserT s st m ()
@@ -1451,17 +1455,26 @@ singleQuoteEnd = try $ do
1451 charOrRef "'\8217\146"
1455 charOrRef "'\8217\146"
1452 notFollowedBy alphaNum
1456 notFollowedBy alphaNum
1458+doubleQuoteStart :: (HasLastStrPosition st,
1454−doubleQuoteStart :: (HasQuoteContext st m, Stream s m Char)
1459+ HasQuoteContext st m,
1455 => ParserT s st m ()
1461 => ParserT s st m ()
1456doubleQuoteStart = do
1462doubleQuoteStart = do
1457 failIfInQuoteContext InDoubleQuote
1463 failIfInQuoteContext InDoubleQuote
1464+ guard =<< notAfterString
1458 try $ do charOrRef "\"\8220\147"
1465 try $ do charOrRef "\"\8220\147"
1459− notFollowedBy (oneOf [' ', '\t', '\n'])
1466+ notFollowedBy (satisfy isSpaceChar)
1461doubleQuoteEnd :: Stream s m Char
1468doubleQuoteEnd :: Stream s m Char
1462 => ParserT s st m ()
1469 => ParserT s st m ()
1463doubleQuoteEnd = void (charOrRef "\"\8221\148")
1470doubleQuoteEnd = void (charOrRef "\"\8221\148")
1472+apostrophe :: Stream s m Char => ParserT s st m Inlines
1473+apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\8217")
1475+doubleCloseQuote :: Stream s m Char => ParserT s st m Inlines
1476+doubleCloseQuote = B.str "\8221" <$ char '"'
1465ellipses :: Stream s m Char
1478ellipses :: Stream s m Char
1466 => ParserT s st m Inlines
1479 => ParserT s st m Inlines
1467ellipses = try (string "..." >> return (B.str "\8230"))
1480ellipses = try (string "..." >> return (B.str "\8230"))