aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/CSS.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/CSS.hs')
-rw-r--r--src/Text/Pandoc/CSS.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Text/Pandoc/CSS.hs b/src/Text/Pandoc/CSS.hs
index 3f88d2006..80251850b 100644
--- a/src/Text/Pandoc/CSS.hs
+++ b/src/Text/Pandoc/CSS.hs
@@ -11,13 +11,13 @@ Portability : portable
Tools for working with CSS.
-}
-module Text.Pandoc.CSS ( foldOrElse
- , pickStyleAttrProps
+module Text.Pandoc.CSS ( pickStyleAttrProps
, pickStylesToKVs
)
where
import qualified Data.Text as T
+import Data.Maybe (mapMaybe, listToMaybe)
import Text.Pandoc.Shared (trim)
import Text.Parsec
import Text.Parsec.Text
@@ -31,12 +31,6 @@ ruleParser = do
styleAttrParser :: Parser [(T.Text, T.Text)]
styleAttrParser = many1 ruleParser
-orElse :: Eq a => a -> a -> a -> a
-orElse v x y = if v == x then y else x
-
-foldOrElse :: Eq a => a -> [a] -> a
-foldOrElse v xs = foldr (orElse v) v xs
-
eitherToMaybe :: Either a b -> Maybe b
eitherToMaybe (Right x) = Just x
eitherToMaybe _ = Nothing
@@ -54,4 +48,4 @@ pickStylesToKVs props styleAttr =
pickStyleAttrProps :: [T.Text] -> T.Text -> Maybe T.Text
pickStyleAttrProps lookupProps styleAttr = do
styles <- eitherToMaybe $ parse styleAttrParser "" styleAttr
- foldOrElse Nothing $ map (`lookup` styles) lookupProps
+ listToMaybe $ mapMaybe (`lookup` styles) lookupProps