@@ -280,7 +280,10 @@ escapeString opts = escapeStringUsing markdownEscapes
280280 (if isEnabled Ext_tex_math_dollars opts
281281 then ('$':)
282282 else id) $
283− "\\`*_[]#"
283+ "\\`*_[]#" ++
284+ if isEnabled Ext_smart opts
285+ then "\"'"
286+ else ""
284287
285288-- | Construct table of contents from list of header blocks.
286289tableOfContents :: PandocMonad m => WriterOptions -> [Block] -> m Doc
@@ -949,10 +952,14 @@ inlineToMarkdown opts (SmallCaps lst) = do
949952 else inlineListToMarkdown opts $ capitalize lst
950953inlineToMarkdown opts (Quoted SingleQuote lst) = do
951954 contents <- inlineListToMarkdown opts lst
952− return $ "‘" <> contents <> "’"
955+ return $ if isEnabled Ext_smart opts
956+ then "'" <> contents <> "'"
957+ else "‘" <> contents <> "’"
953958inlineToMarkdown opts (Quoted DoubleQuote lst) = do
954959 contents <- inlineListToMarkdown opts lst
955− return $ "“" <> contents <> "”"
960+ return $ if isEnabled Ext_smart opts
961+ then "\"" <> contents <> "\""
962+ else "“" <> contents <> "”"
956963inlineToMarkdown opts (Code attr str) = do
957964 let tickGroups = filter (\s -> '`' `elem` s) $ group str
958965 let longest = if null tickGroups
@@ -969,9 +976,13 @@ inlineToMarkdown opts (Code attr str) = do
969976 else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs
970977inlineToMarkdown opts (Str str) = do
971978 isPlain <- asks envPlain
972− if isPlain
973− then return $ text str
974− else return $ text $ escapeString opts str
979+ let str' = (if isEnabled Ext_smart opts
980+ then unsmartify opts
981+ else id) $
982+ if isPlain
983+ then str
984+ else escapeString opts str
985+ return $ text str'
975986inlineToMarkdown opts (Math InlineMath str) =
976987 case writerHTMLMathMethod opts of
977988 WebTeX url ->
@@ -1126,3 +1137,15 @@ makeMathPlainer = walk go
11261137 go (Emph xs) = Span nullAttr xs
11271138 go x = x
11281139
1140+unsmartify :: WriterOptions -> String -> String
1141+unsmartify opts ('\8217':xs) = '\'' : unsmartify opts xs
1142+unsmartify opts ('\8230':xs) = "..." ++ unsmartify opts xs
1143+unsmartify opts ('\8211':xs)
1144+ | isEnabled Ext_old_dashes opts = '-' : unsmartify opts xs
1145+ | otherwise = "--" ++ unsmartify opts xs
1146+unsmartify opts ('\8212':xs)
1147+ | isEnabled Ext_old_dashes opts = "--" ++ unsmartify opts xs
1148+ | otherwise = "---" ++ unsmartify opts xs
1149+unsmartify opts (x:xs) = x : unsmartify opts xs
1150+unsmartify _ [] = []
1151+