{-# LANGUAGE FlexibleInstances #-}
module LiterateX
(
version
, transformTextToText
, transformTextToHandle
, transformTextToFile
, transformHandleToText
, transformHandleToHandle
, transformHandleToFile
, transformFileToText
, transformFileToHandle
, transformFileToFile
, runPure
, runIO
, runResource
, sourceString
, sourceText
, sourceLazyText
, sourceByteString
, sourceLazyByteString
, sourceHandle
, sourceFile
, sinkString
, sinkText
, sinkLazyText
, sinkByteString
, sinkLazyByteString
, sinkHandle
, sinkFile
, transform
) where
import Control.Monad.IO.Class (MonadIO)
import Data.Version (showVersion)
import System.IO (Handle)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL
import qualified Conduit as C
import Data.Conduit ((.|))
import qualified Data.Conduit.Combinators as CC
import qualified Data.Conduit.List as CL
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Data.Text.Encoding.Error as TEE
import qualified Data.Text.Lazy as TL
import UnliftIO (MonadUnliftIO)
import qualified LiterateX.Parser as Parser
import qualified LiterateX.Renderer as Renderer
import LiterateX.Types (SourceFormat)
import qualified Paths_literatex as Project
version :: String
version :: [Char]
version = [Char]
"literatex-haskell " forall a. [a] -> [a] -> [a]
++ Version -> [Char]
showVersion Version
Project.version
transformTextToText
:: SourceFormat
-> Renderer.Options
-> TL.Text
-> TL.Text
transformTextToText :: SourceFormat -> Options -> Text -> Text
transformTextToText SourceFormat
sourceFormat Options
rendererOpts Text
source =
forall r.
SourceFormat
-> Options
-> ConduitT () Text Identity ()
-> ConduitT Text Void Identity r
-> r
runPure SourceFormat
sourceFormat Options
rendererOpts (forall (m :: * -> *) i. Monad m => Text -> ConduitT i Text m ()
sourceLazyText Text
source) forall (m :: * -> *) o. Monad m => ConduitT Text o m Text
sinkLazyText
transformTextToHandle
:: MonadIO m
=> SourceFormat
-> Renderer.Options
-> TL.Text
-> Handle
-> m ()
transformTextToHandle :: forall (m :: * -> *).
MonadIO m =>
SourceFormat -> Options -> Text -> Handle -> m ()
transformTextToHandle SourceFormat
sourceFormat Options
rendererOpts Text
source Handle
target =
forall (m :: * -> *) r.
MonadIO m =>
SourceFormat
-> Options
-> ConduitT () Text m ()
-> ConduitT Text Void m r
-> m r
runIO SourceFormat
sourceFormat Options
rendererOpts
(forall (m :: * -> *) i. Monad m => Text -> ConduitT i Text m ()
sourceLazyText Text
source)
(forall (m :: * -> *) o. MonadIO m => Handle -> ConduitT Text o m ()
sinkHandle Handle
target)
transformTextToFile
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> TL.Text
-> FilePath
-> m ()
transformTextToFile :: forall (m :: * -> *).
MonadUnliftIO m =>
SourceFormat -> Options -> Text -> [Char] -> m ()
transformTextToFile SourceFormat
sourceFormat Options
rendererOpts Text
source [Char]
target =
forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts
(forall (m :: * -> *) i. Monad m => Text -> ConduitT i Text m ()
sourceLazyText Text
source)
(forall (m :: * -> *) o.
MonadResource m =>
[Char] -> ConduitT Text o m ()
sinkFile [Char]
target)
transformHandleToText
:: MonadIO m
=> SourceFormat
-> Renderer.Options
-> Handle
-> m TL.Text
transformHandleToText :: forall (m :: * -> *).
MonadIO m =>
SourceFormat -> Options -> Handle -> m Text
transformHandleToText SourceFormat
sourceFormat Options
rendererOpts Handle
source =
forall (m :: * -> *) r.
MonadIO m =>
SourceFormat
-> Options
-> ConduitT () Text m ()
-> ConduitT Text Void m r
-> m r
runIO SourceFormat
sourceFormat Options
rendererOpts (forall (m :: * -> *) i. MonadIO m => Handle -> ConduitT i Text m ()
sourceHandle Handle
source) forall (m :: * -> *) o. Monad m => ConduitT Text o m Text
sinkLazyText
transformHandleToHandle
:: MonadIO m
=> SourceFormat
-> Renderer.Options
-> Handle
-> Handle
-> m ()
transformHandleToHandle :: forall (m :: * -> *).
MonadIO m =>
SourceFormat -> Options -> Handle -> Handle -> m ()
transformHandleToHandle SourceFormat
sourceFormat Options
rendererOpts Handle
source Handle
target =
forall (m :: * -> *) r.
MonadIO m =>
SourceFormat
-> Options
-> ConduitT () Text m ()
-> ConduitT Text Void m r
-> m r
runIO SourceFormat
sourceFormat Options
rendererOpts (forall (m :: * -> *) i. MonadIO m => Handle -> ConduitT i Text m ()
sourceHandle Handle
source) (forall (m :: * -> *) o. MonadIO m => Handle -> ConduitT Text o m ()
sinkHandle Handle
target)
transformHandleToFile
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> Handle
-> FilePath
-> m ()
transformHandleToFile :: forall (m :: * -> *).
MonadUnliftIO m =>
SourceFormat -> Options -> Handle -> [Char] -> m ()
transformHandleToFile SourceFormat
sourceFormat Options
rendererOpts Handle
source [Char]
target =
forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts
(forall (m :: * -> *) i. MonadIO m => Handle -> ConduitT i Text m ()
sourceHandle Handle
source)
(forall (m :: * -> *) o.
MonadResource m =>
[Char] -> ConduitT Text o m ()
sinkFile [Char]
target)
transformFileToText
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> FilePath
-> m TL.Text
transformFileToText :: forall (m :: * -> *).
MonadUnliftIO m =>
SourceFormat -> Options -> [Char] -> m Text
transformFileToText SourceFormat
sourceFormat Options
rendererOpts [Char]
source =
forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts (forall (m :: * -> *) i.
MonadResource m =>
[Char] -> ConduitT i Text m ()
sourceFile [Char]
source) forall (m :: * -> *) o. Monad m => ConduitT Text o m Text
sinkLazyText
transformFileToHandle
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> FilePath
-> Handle
-> m ()
transformFileToHandle :: forall (m :: * -> *).
MonadUnliftIO m =>
SourceFormat -> Options -> [Char] -> Handle -> m ()
transformFileToHandle SourceFormat
sourceFormat Options
rendererOpts [Char]
source Handle
target =
forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts
(forall (m :: * -> *) i.
MonadResource m =>
[Char] -> ConduitT i Text m ()
sourceFile [Char]
source)
(forall (m :: * -> *) o. MonadIO m => Handle -> ConduitT Text o m ()
sinkHandle Handle
target)
transformFileToFile
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> FilePath
-> FilePath
-> m ()
transformFileToFile :: forall (m :: * -> *).
MonadUnliftIO m =>
SourceFormat -> Options -> [Char] -> [Char] -> m ()
transformFileToFile SourceFormat
sourceFormat Options
rendererOpts [Char]
source [Char]
target =
forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts
(forall (m :: * -> *) i.
MonadResource m =>
[Char] -> ConduitT i Text m ()
sourceFile [Char]
source)
(forall (m :: * -> *) o.
MonadResource m =>
[Char] -> ConduitT Text o m ()
sinkFile [Char]
target)
runPure
:: SourceFormat
-> Renderer.Options
-> C.ConduitT () T.Text C.Identity ()
-> C.ConduitT T.Text C.Void C.Identity r
-> r
runPure :: forall r.
SourceFormat
-> Options
-> ConduitT () Text Identity ()
-> ConduitT Text Void Identity r
-> r
runPure SourceFormat
sourceFormat Options
rendererOpts ConduitT () Text Identity ()
source ConduitT Text Void Identity r
sink = forall r. ConduitT () Void Identity r -> r
C.runConduitPure forall a b. (a -> b) -> a -> b
$
ConduitT () Text Identity ()
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
Monad m =>
SourceFormat -> Options -> ConduitT Text Text m ()
transform SourceFormat
sourceFormat Options
rendererOpts forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| ConduitT Text Void Identity r
sink
runIO
:: MonadIO m
=> SourceFormat
-> Renderer.Options
-> C.ConduitT () T.Text m ()
-> C.ConduitT T.Text C.Void m r
-> m r
runIO :: forall (m :: * -> *) r.
MonadIO m =>
SourceFormat
-> Options
-> ConduitT () Text m ()
-> ConduitT Text Void m r
-> m r
runIO SourceFormat
sourceFormat Options
rendererOpts ConduitT () Text m ()
source ConduitT Text Void m r
sink = forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
C.runConduit forall a b. (a -> b) -> a -> b
$
ConduitT () Text m ()
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
Monad m =>
SourceFormat -> Options -> ConduitT Text Text m ()
transform SourceFormat
sourceFormat Options
rendererOpts forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| ConduitT Text Void m r
sink
runResource
:: MonadUnliftIO m
=> SourceFormat
-> Renderer.Options
-> C.ConduitT () T.Text (C.ResourceT m) ()
-> C.ConduitT T.Text C.Void (C.ResourceT m) r
-> m r
runResource :: forall (m :: * -> *) r.
MonadUnliftIO m =>
SourceFormat
-> Options
-> ConduitT () Text (ResourceT m) ()
-> ConduitT Text Void (ResourceT m) r
-> m r
runResource SourceFormat
sourceFormat Options
rendererOpts ConduitT () Text (ResourceT m) ()
source ConduitT Text Void (ResourceT m) r
sink = forall (m :: * -> *) r.
MonadUnliftIO m =>
ConduitT () Void (ResourceT m) r -> m r
C.runConduitRes forall a b. (a -> b) -> a -> b
$
ConduitT () Text (ResourceT m) ()
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
Monad m =>
SourceFormat -> Options -> ConduitT Text Text m ()
transform SourceFormat
sourceFormat Options
rendererOpts forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| ConduitT Text Void (ResourceT m) r
sink
sourceString
:: Monad m
=> String
-> C.ConduitT i T.Text m ()
sourceString :: forall (m :: * -> *) i. Monad m => [Char] -> ConduitT i Text m ()
sourceString = forall (m :: * -> *) mono i.
(Monad m, MonoFoldable mono) =>
mono -> ConduitT i (Element mono) m ()
CC.yieldMany forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map [Char] -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
lines
sourceText
:: Monad m
=> T.Text
-> C.ConduitT i T.Text m ()
sourceText :: forall (m :: * -> *) i. Monad m => Text -> ConduitT i Text m ()
sourceText Text
source = forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
C.yield Text
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.linesUnbounded
sourceLazyText
:: Monad m
=> TL.Text
-> C.ConduitT i T.Text m ()
sourceLazyText :: forall (m :: * -> *) i. Monad m => Text -> ConduitT i Text m ()
sourceLazyText Text
source = forall (m :: * -> *) lazy strict i.
(Monad m, LazySequence lazy strict) =>
lazy -> ConduitT i strict m ()
CC.sourceLazy Text
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.linesUnbounded
sourceByteString
:: Monad m
=> BS.ByteString
-> C.ConduitT i T.Text m ()
sourceByteString :: forall (m :: * -> *) i.
Monad m =>
ByteString -> ConduitT i Text m ()
sourceByteString ByteString
source =
forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
C.yield ByteString
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.linesUnboundedAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *). Monad m => ConduitT ByteString Text m ()
decodeUtf8LinesLenient
sourceLazyByteString
:: Monad m
=> BSL.ByteString
-> C.ConduitT i T.Text m ()
sourceLazyByteString :: forall (m :: * -> *) i.
Monad m =>
ByteString -> ConduitT i Text m ()
sourceLazyByteString ByteString
source =
forall (m :: * -> *) lazy strict i.
(Monad m, LazySequence lazy strict) =>
lazy -> ConduitT i strict m ()
CC.sourceLazy ByteString
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.linesUnboundedAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *). Monad m => ConduitT ByteString Text m ()
decodeUtf8LinesLenient
sourceHandle
:: MonadIO m
=> Handle
-> C.ConduitT i T.Text m ()
sourceHandle :: forall (m :: * -> *) i. MonadIO m => Handle -> ConduitT i Text m ()
sourceHandle Handle
source =
forall (m :: * -> *) i.
MonadIO m =>
Handle -> ConduitT i ByteString m ()
CC.sourceHandle Handle
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.linesUnboundedAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *). Monad m => ConduitT ByteString Text m ()
decodeUtf8LinesLenient
sourceFile
:: C.MonadResource m
=> FilePath
-> C.ConduitT i T.Text m ()
sourceFile :: forall (m :: * -> *) i.
MonadResource m =>
[Char] -> ConduitT i Text m ()
sourceFile [Char]
source =
forall (m :: * -> *) i.
MonadResource m =>
[Char] -> ConduitT i ByteString m ()
CC.sourceFile [Char]
source forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.linesUnboundedAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *). Monad m => ConduitT ByteString Text m ()
decodeUtf8LinesLenient
sinkString
:: Monad m
=> C.ConduitT T.Text o m String
sinkString :: forall (m :: * -> *) o. Monad m => ConduitT Text o m [Char]
sinkString = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> [Char]
TL.unpack forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.unlines forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) lazy strict o.
(Monad m, LazySequence lazy strict) =>
ConduitT strict o m lazy
CC.sinkLazy
sinkText
:: Monad m
=> C.ConduitT T.Text o m T.Text
sinkText :: forall (m :: * -> *) o. Monad m => ConduitT Text o m Text
sinkText = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Text
TL.toStrict forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.unlines forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) lazy strict o.
(Monad m, LazySequence lazy strict) =>
ConduitT strict o m lazy
CC.sinkLazy
sinkLazyText
:: Monad m
=> C.ConduitT T.Text o m TL.Text
sinkLazyText :: forall (m :: * -> *) o. Monad m => ConduitT Text o m Text
sinkLazyText = forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.unlines forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) lazy strict o.
(Monad m, LazySequence lazy strict) =>
ConduitT strict o m lazy
CC.sinkLazy
sinkByteString
:: Monad m
=> C.ConduitT T.Text o m BS.ByteString
sinkByteString :: forall (m :: * -> *) o. Monad m => ConduitT Text o m ByteString
sinkByteString =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> ByteString
BSL.toStrict forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.unlines forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) text binary.
(Monad m, Utf8 text binary) =>
ConduitT text binary m ()
CC.encodeUtf8 forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) lazy strict o.
(Monad m, LazySequence lazy strict) =>
ConduitT strict o m lazy
CC.sinkLazy
sinkLazyByteString
:: Monad m
=> C.ConduitT T.Text o m BSL.ByteString
sinkLazyByteString :: forall (m :: * -> *) o. Monad m => ConduitT Text o m ByteString
sinkLazyByteString = forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Char) =>
ConduitT seq seq m ()
CC.unlines forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) text binary.
(Monad m, Utf8 text binary) =>
ConduitT text binary m ()
CC.encodeUtf8 forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) lazy strict o.
(Monad m, LazySequence lazy strict) =>
ConduitT strict o m lazy
CC.sinkLazy
sinkHandle
:: MonadIO m
=> Handle
-> C.ConduitT T.Text o m ()
sinkHandle :: forall (m :: * -> *) o. MonadIO m => Handle -> ConduitT Text o m ()
sinkHandle Handle
target = forall (m :: * -> *) text binary.
(Monad m, Utf8 text binary) =>
ConduitT text binary m ()
CC.encodeUtf8 forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.unlinesAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) o.
MonadIO m =>
Handle -> ConduitT ByteString o m ()
CC.sinkHandle Handle
target
sinkFile
:: C.MonadResource m
=> FilePath
-> C.ConduitT T.Text o m ()
sinkFile :: forall (m :: * -> *) o.
MonadResource m =>
[Char] -> ConduitT Text o m ()
sinkFile [Char]
target = forall (m :: * -> *) text binary.
(Monad m, Utf8 text binary) =>
ConduitT text binary m ()
CC.encodeUtf8 forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) seq.
(Monad m, IsSequence seq, Element seq ~ Word8) =>
ConduitT seq seq m ()
CC.unlinesAscii forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) o.
MonadResource m =>
[Char] -> ConduitT ByteString o m ()
CC.sinkFile [Char]
target
transform
:: Monad m
=> SourceFormat
-> Renderer.Options
-> C.ConduitT T.Text T.Text m ()
transform :: forall (m :: * -> *).
Monad m =>
SourceFormat -> Options -> ConduitT Text Text m ()
transform SourceFormat
sourceFormat Options
rendererOpts
= forall (m :: * -> *).
Monad m =>
SourceFormat -> ConduitT Text SourceLine m ()
Parser.parse SourceFormat
sourceFormat
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) a accum b.
Monad m =>
(a -> accum -> (accum, [b])) -> accum -> ConduitT a b m ()
CL.concatMapAccum (\SourceLine
x Int
n -> (Int
n forall a. Num a => a -> a -> a
+ Int
1, [(Int
n, SourceLine
x)])) Int
1
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
Monad m =>
Options -> ConduitT (Int, SourceLine) Text m ()
Renderer.render Options
rendererOpts
decodeUtf8LinesLenient
:: Monad m
=> C.ConduitT BS.ByteString T.Text m ()
decodeUtf8LinesLenient :: forall (m :: * -> *). Monad m => ConduitT ByteString Text m ()
decodeUtf8LinesLenient =
forall (m :: * -> *) i o r.
Monad m =>
(i -> ConduitT i o m r) -> ConduitT i o m ()
C.awaitForever forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
C.yield forall b c a. (b -> c) -> (a -> b) -> a -> c
. OnDecodeError -> ByteString -> Text
TE.decodeUtf8With OnDecodeError
TEE.lenientDecode