@@ -161,8 +161,22 @@ pictToRST (label, (attr, src, _, mbtarget)) = do
161161 Just t -> " :target: " <> text t
162162
163163-- | Escape special characters for RST.
164−escapeString :: String -> String
165−escapeString = escapeStringUsing (backslashEscapes "`\\|*_")
164+escapeString :: WriterOptions -> String -> String
165+escapeString _ [] = []
166+escapeString opts (c:cs) =
167+ case c of
168+ _ | c `elem` ['\\','`','*','_','|'] -> '\\':c:escapeString opts cs
169+ '\'' | isEnabled Ext_smart opts -> '\\':'\'':escapeString opts cs
170+ '"' | isEnabled Ext_smart opts -> '\\':'"':escapeString opts cs
171+ '-' | isEnabled Ext_smart opts ->
172+ case cs of
173+ '-':_ -> '\\':'-':escapeString opts cs
174+ _ -> '-':escapeString opts cs
175+ '.' | isEnabled Ext_smart opts ->
176+ case cs of
177+ '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest
178+ _ -> '.':escapeString opts cs
179+ _ -> c : escapeString opts cs
166180
167181titleToRST :: [Inline] -> [Inline] -> State WriterState Doc
168182titleToRST [] _ = return empty
@@ -447,10 +461,10 @@ inlineToRST (Cite _ lst) =
447461inlineToRST (Code _ str) = return $ "``" <> text str <> "``"
448462inlineToRST (Str str) = do
449463 opts <- gets stOptions
450− let str' = if isEnabled Ext_smart opts
451− then unsmartify opts str
452− else str
453− return $ text $ escapeString str'
464+ return $ text $
465+ (if isEnabled Ext_smart opts
466+ then unsmartify opts
467+ else id) $ escapeString opts str
454468inlineToRST (Math t str) = do
455469 modify $ \st -> st{ stHasMath = True }
456470 return $ if t == InlineMath