{-# LANGUAGE LambdaCase #-}
module Text.MMark.Trans
( applyBlockTrans
, applyInlineTrans )
where
import Data.Monoid hiding ((<>))
import Text.MMark.Type
applyBlockTrans :: Endo Bni -> Bni -> Bni
applyBlockTrans trans@(Endo f) = \case
Blockquote xs -> f (Blockquote (s xs))
OrderedList w xs -> f (OrderedList w (s <$> xs))
UnorderedList xs -> f (UnorderedList (s <$> xs))
other -> f other
where
s = fmap (applyBlockTrans trans)
applyInlineTrans :: Endo Inline -> Inline -> Inline
applyInlineTrans trans@(Endo f) = \case
Emphasis xs -> f (Emphasis (s xs))
Strong xs -> f (Strong (s xs))
Strikeout xs -> f (Strikeout (s xs))
Subscript xs -> f (Subscript (s xs))
Superscript xs -> f (Superscript (s xs))
Link xs uri mt -> f (Link (s xs) uri mt)
Image xs uri mt -> f (Image (s xs) uri mt)
other -> f other
where
s = fmap (applyInlineTrans trans)