summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs14
-rw-r--r--src/Text/Pandoc/Readers/Org.hs2
-rw-r--r--src/Text/Pandoc/Readers/RST.hs5
3 files changed, 9 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 86ce62ced..be486c83f 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -86,7 +86,7 @@ import Text.Pandoc.Readers.Docx.TexChar
import Text.Pandoc.Shared
import Text.Pandoc.MediaBag (insertMedia, MediaBag)
import Data.Maybe (mapMaybe, fromMaybe)
-import Data.List (delete, isPrefixOf, (\\), intercalate, intersect)
+import Data.List (delete, stripPrefix, (\\), intercalate, intersect)
import Data.Monoid
import qualified Data.ByteString.Lazy as B
import qualified Data.Map as M
@@ -455,8 +455,8 @@ oMathElemToTexString (LowerLimit base limElems) = do
-- we want to make sure to replace the `\rightarrow` with `\to`
let arrowToTo :: String -> String
arrowToTo "" = ""
- arrowToTo s | "\\rightarrow" `isPrefixOf` s =
- "\\to" ++ (arrowToTo $ drop (length "\\rightarrow") s)
+ arrowToTo s | Just s' <- stripPrefix "\\rightarrow" s =
+ "\\to" ++ arrowToTo s'
arrowToTo (c:cs) = c : arrowToTo cs
lim' = arrowToTo lim
return $ case baseString of
@@ -470,8 +470,8 @@ oMathElemToTexString (UpperLimit base limElems) = do
-- we want to make sure to replace the `\rightarrow` with `\to`
let arrowToTo :: String -> String
arrowToTo "" = ""
- arrowToTo s | "\\rightarrow" `isPrefixOf` s =
- "\\to" ++ (arrowToTo $ drop (length "\\rightarrow") s)
+ arrowToTo s | Just s' <- stripPrefix "\\rightarrow" s =
+ "\\to" ++ arrowToTo s'
arrowToTo (c:cs) = c : arrowToTo cs
lim' = arrowToTo lim
return $ case baseString of
@@ -698,8 +698,8 @@ ilToCode Space = " "
ilToCode _ = ""
isHeaderClass :: String -> Maybe Int
-isHeaderClass s | "Heading" `isPrefixOf` s =
- case reads (drop (length "Heading") s) :: [(Int, String)] of
+isHeaderClass s | Just s' <- stripPrefix "Heading" s =
+ case reads s' :: [(Int, String)] of
[] -> Nothing
((n, "") : []) -> Just n
_ -> Nothing
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 065f5a046..e1c29d1e8 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -274,7 +274,7 @@ optionalAttributes parser = try $
parseBlockAttributes :: OrgParser ()
parseBlockAttributes = do
attrs <- many attribute
- () <$ mapM (uncurry parseAndAddAttribute) attrs
+ mapM_ (uncurry parseAndAddAttribute) attrs
where
attribute :: OrgParser (String, String)
attribute = try $ do
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index b7bc83e86..e5eccb116 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -47,7 +47,7 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))
import qualified Text.Pandoc.Builder as B
import Data.Monoid (mconcat, mempty)
import Data.Sequence (viewr, ViewR(..))
-import Data.Char (toLower)
+import Data.Char (toLower, isHexDigit)
-- | Parse reStructuredText string and return Pandoc document.
readRST :: ReaderOptions -- ^ Reader options
@@ -656,9 +656,6 @@ extractUnicodeChar s = maybe Nothing (\c -> Just (c,rest)) mbc
where (ds,rest) = span isHexDigit s
mbc = safeRead ('\'':'\\':'x':ds ++ "'")
-isHexDigit :: Char -> Bool
-isHexDigit c = c `elem` "0123456789ABCDEFabcdef"
-
extractCaption :: RSTParser (Inlines, Blocks)
extractCaption = do
capt <- trimInlines . mconcat <$> many inline