@@ -280,7 +280,10 @@ escapeString opts = escapeStringUsing markdownEscapes
280 (if isEnabled Ext_tex_math_dollars opts
280 (if isEnabled Ext_tex_math_dollars opts
281 then ('$':)
281 then ('$':)
282 else id) $
282 else id) $
283− "\\`*_[]#"
283+ "\\`*_[]#" ++
284+ if isEnabled Ext_smart opts
285-- | Construct table of contents from list of header blocks.
288-- | Construct table of contents from list of header blocks.
286tableOfContents :: PandocMonad m => WriterOptions -> [Block] -> m Doc
289tableOfContents :: PandocMonad m => WriterOptions -> [Block] -> m Doc
@@ -949,10 +952,14 @@ inlineToMarkdown opts (SmallCaps lst) = do
949 else inlineListToMarkdown opts $ capitalize lst
952 else inlineListToMarkdown opts $ capitalize lst
950inlineToMarkdown opts (Quoted SingleQuote lst) = do
953inlineToMarkdown opts (Quoted SingleQuote lst) = do
951 contents <- inlineListToMarkdown opts lst
954 contents <- inlineListToMarkdown opts lst
955+ return $ if isEnabled Ext_smart opts
956+ then "'" <> contents <> "'"
952− return $ "‘" <> contents <> "’"
957+ else "‘" <> contents <> "’"
953inlineToMarkdown opts (Quoted DoubleQuote lst) = do
958inlineToMarkdown opts (Quoted DoubleQuote lst) = do
954 contents <- inlineListToMarkdown opts lst
959 contents <- inlineListToMarkdown opts lst
960+ return $ if isEnabled Ext_smart opts
961+ then "\"" <> contents <> "\""
955− return $ "“" <> contents <> "”"
962+ else "“" <> contents <> "”"
956inlineToMarkdown opts (Code attr str) = do
963inlineToMarkdown opts (Code attr str) = do
957 let tickGroups = filter (\s -> '`' `elem` s) $ group str
964 let tickGroups = filter (\s -> '`' `elem` s) $ group str
958 let longest = if null tickGroups
965 let longest = if null tickGroups
@@ -969,9 +976,13 @@ inlineToMarkdown opts (Code attr str) = do
969 else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs
976 else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs
970inlineToMarkdown opts (Str str) = do
977inlineToMarkdown opts (Str str) = do
971 isPlain <- asks envPlain
978 isPlain <- asks envPlain
979+ let str' = (if isEnabled Ext_smart opts
980+ then unsmartify opts
972− if isPlain
982+ if isPlain
973− then return $ text str
983+ then str
974− else return $ text $ escapeString opts str
984+ else escapeString opts str
975inlineToMarkdown opts (Math InlineMath str) =
986inlineToMarkdown opts (Math InlineMath str) =
976 case writerHTMLMathMethod opts of
987 case writerHTMLMathMethod opts of
977 WebTeX url ->
988 WebTeX url ->
@@ -1126,3 +1137,15 @@ makeMathPlainer = walk go
1126 go (Emph xs) = Span nullAttr xs
1137 go (Emph xs) = Span nullAttr xs
1127 go x = x
1138 go x = x
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 _ [] = []