{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Emoji ( emojis, emojiToInline ) where
import qualified Text.Emoji as E
import Text.Pandoc.Definition (Inline (Span, Str))
import Data.Text (Text)
import qualified Data.Map as M
emojis :: M.Map Text Text
emojis :: Map Text Text
emojis = [(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Text, Text)]
E.emojis
emojiToInline :: Text -> Maybe Inline
emojiToInline :: Text -> Maybe Inline
emojiToInline Text
emojikey = Text -> Inline
makeSpan (Text -> Inline) -> Maybe Text -> Maybe Inline
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Maybe Text
E.emojiFromAlias Text
emojikey
where makeSpan :: Text -> Inline
makeSpan = Attr -> [Inline] -> Inline
Span (Text
"", [Text
"emoji"], [(Text
"data-emoji", Text
emojikey)]) ([Inline] -> Inline) -> (Text -> [Inline]) -> Text -> Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> [Inline] -> [Inline]
forall a. a -> [a] -> [a]
:[]) (Inline -> [Inline]) -> (Text -> Inline) -> Text -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inline
Str