diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-02-04 12:52:08 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-02-04 12:52:08 +0100 |
commit | 8418c1a7d7e5312dfddbc011adb257552b2a864b (patch) | |
tree | b45a1b0bd3a5237d366b1b6528e5fe7d4e80b8d0 /src/Text/Pandoc/Writers/Shared.hs | |
parent | 1feddee6d684840100998e457b728c441d1f8f53 (diff) | |
download | pandoc-8418c1a7d7e5312dfddbc011adb257552b2a864b.tar.gz |
Implemented +/-smart in rst writer.
Moved unsmartify to Writers.Shared.
Diffstat (limited to 'src/Text/Pandoc/Writers/Shared.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Shared.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 845d22077..3d50d3312 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -35,10 +35,12 @@ module Text.Pandoc.Writers.Shared ( , defField , tagWithAttrs , fixDisplayMath + , unsmartify ) where import Text.Pandoc.Definition import Text.Pandoc.Pretty +import Text.Pandoc.Options import Text.Pandoc.XML (escapeStringForXML) import Control.Monad (liftM) import Text.Pandoc.Options (WriterOptions(..)) @@ -167,3 +169,16 @@ fixDisplayMath (Para lst) groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || not (isDisplayMath x || isDisplayMath y)) lst fixDisplayMath x = x + +unsmartify :: WriterOptions -> String -> String +unsmartify opts ('\8217':xs) = '\'' : unsmartify opts xs +unsmartify opts ('\8230':xs) = "..." ++ unsmartify opts xs +unsmartify opts ('\8211':xs) + | isEnabled Ext_old_dashes opts = '-' : unsmartify opts xs + | otherwise = "--" ++ unsmartify opts xs +unsmartify opts ('\8212':xs) + | isEnabled Ext_old_dashes opts = "--" ++ unsmartify opts xs + | otherwise = "---" ++ unsmartify opts xs +unsmartify opts (x:xs) = x : unsmartify opts xs +unsmartify _ [] = [] + |