{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
module Knit.Report.Input.Html
(
addStrictTextHtml
, addLazyTextHtml
, htmlReaderOptions
, htmlReaderOptionsWithHeader
)
where
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import qualified Text.Pandoc as P
import qualified Text.Pandoc.Extensions as PA
import qualified Polysemy as P
import qualified Knit.Effect.Pandoc as PE
import qualified Knit.Effect.PandocMonad as PM
htmlReaderOptions :: P.ReaderOptions
htmlReaderOptions =
P.def { P.readerExtensions = PA.extensionsFromList [PA.Ext_raw_html] }
htmlReaderOptionsWithHeader :: P.ReaderOptions
htmlReaderOptionsWithHeader = htmlReaderOptions { P.readerStandalone = True }
addStrictTextHtml
:: (PM.PandocEffects effs, P.Member PE.ToPandoc effs)
=> T.Text
-> P.Sem effs ()
addStrictTextHtml = PE.addFrom PE.ReadHtml htmlReaderOptions
addLazyTextHtml
:: (PM.PandocEffects effs, P.Member PE.ToPandoc effs)
=> LT.Text
-> P.Sem effs ()
addLazyTextHtml = addStrictTextHtml . LT.toStrict