{-# LANGUAGE ScopedTypeVariables #-}
module Text.Pandoc.Util.Filter.Styling
(styling, inlineStyling)
where
import Text.Pandoc.JSON
import Data.Monoid ((<>))
import Text.Pandoc.Util.Filter
import Prelude hiding (div, span)
styling :: Block -> IO [Block]
styling (Div ("col",att,att') inner) = return $ [toBlockHtml $ "<div style=\"float:left; margin-bottom:10px;\"" <> unwords direct <> attToString ("",css,att') <> ">"]
++ inner
++ [toBlockHtml"</div>"]
where
(direct, css) = classToRevealAttr att
styling (CodeBlock (id',att,att') inner) = return
[CodeBlock (id', addToAtt "data-trim"
. addToAtt "data-noescape"
$ att
, att')
inner]
styling div@(Div (id',att,att') inner)
| "fragment" `elem` att = return [Div (id', att, addToStyle "display: block;" att') inner]
| "frame" `elem` att = return [Div (id', addToAtt "fragment"
. addToAtt "current-visible"
. filter (/= "frame")
$ att
, addToStyle "display: block;" att') inner]
| otherwise = return [div]
styling x = return [x]
inlineStyling :: Inline -> Inline
inlineStyling span@(Span (id', att, att') inner)
| "fragment" `elem` att = Span (id', att, addToStyle "display: inline-block;" att') inner
| "frame" `elem` att = Span (id', addToAtt "fragment"
. addToAtt "current-visible"
. filter (/= "frame")
$ att
, addToStyle "display: inline-block;" att') inner
| id' == "vspace" = toHtml $ "<div style=\"clear:both;\"" <> unwords direct <> attToString ("",css,att') <> "></div>"
| id' == "hspace" = toHtml $ "<span " <> unwords direct <> attToString ("",css,att') <> "></span>"
| otherwise = span
where
(direct, css) = classToRevealAttr att
inlineStyling x = x