Copyright | (c) Adam Conner-Sax 2019 |
---|---|
License | BSD-3-Clause |
Maintainer | adam_conner_sax@yahoo.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Polysemy Pandoc effect. This is writer-like, allowing the interspersed addition of various Pandoc-readable formats into one doc and then rendering to many Pandoc-writeable formats. Currently only a subset of formats are supported. Inputs can express requirements, e.g., hvega requires html output because it uses javascript. Those requirements are then checked before output is rendered and an error thrown if the input is not supported.
Synopsis
- data ToPandoc m r
- data FromPandoc m r
- data Requirement
- data PandocWithRequirements
- data PandocReadFormat a where
- data PandocWriteFormat a where
- addFrom :: Member ToPandoc effs => PandocReadFormat a -> ReaderOptions -> a -> Sem effs ()
- require :: Member ToPandoc effs => Requirement -> Sem effs ()
- writeTo :: Member FromPandoc effs => PandocWriteFormat a -> WriterOptions -> Pandoc -> Sem effs a
- toPandoc :: PandocMonad m => PandocReadFormat a -> ReaderOptions -> a -> m Pandoc
- fromPandoc :: PandocMonad m => PandocWriteFormat a -> WriterOptions -> PandocWithRequirements -> m a
- runPandocWriter :: PandocEffects effs => Sem (ToPandoc ': effs) () -> Sem effs PandocWithRequirements
- type Pandocs = Docs PandocWithRequirements
- data NamedDoc a = NamedDoc {}
- newPandoc :: (PandocEffects effs, Member Pandocs effs) => Text -> Sem (ToPandoc ': effs) () -> Sem effs ()
- pandocsToNamed :: PandocEffects effs => PandocWriteFormat a -> WriterOptions -> Sem (Pandocs ': effs) () -> Sem effs [NamedDoc a]
- fromPandocE :: PandocEffects effs => PandocWriteFormat a -> WriterOptions -> Sem (ToPandoc ': effs) () -> Sem effs a
Effects
data FromPandoc m r Source #
Pandoc output effect, take given doc and produce formatted output
Requirement Support
data Requirement Source #
ADT to allow inputs to request support, if necessary or possible, in the output format. E.g., Latex output in Html needs MathJax. But Latex needs to nothing to output in Latex. Vega-lite needs some script headers to output in Html and can't be output in other formats. For now, we support all the things we can in any output format so this just results in a runtime test.
VegaSupport | Supported only for Html output. |
LatexSupport | Supported in Html output (via MathJax) and Latex output. |
Instances
data PandocWithRequirements Source #
Instances
Semigroup PandocWithRequirements Source # | |
Defined in Knit.Effect.Pandoc | |
Monoid PandocWithRequirements Source # | |
Format ADTs
data PandocReadFormat a where Source #
Supported formats for adding to current Pandoc
Instances
Show (PandocReadFormat a) Source # | |
Defined in Knit.Effect.Pandoc showsPrec :: Int -> PandocReadFormat a -> ShowS # show :: PandocReadFormat a -> String # showList :: [PandocReadFormat a] -> ShowS # |
data PandocWriteFormat a where Source #
Supported formats for writing current Pandoc
Instances
Show (PandocWriteFormat a) Source # | |
Defined in Knit.Effect.Pandoc showsPrec :: Int -> PandocWriteFormat a -> ShowS # show :: PandocWriteFormat a -> String # showList :: [PandocWriteFormat a] -> ShowS # |
Combinators
addFrom :: Member ToPandoc effs => PandocReadFormat a -> ReaderOptions -> a -> Sem effs () Source #
Add a piece of a Pandoc readable type to the current doc
require :: Member ToPandoc effs => Requirement -> Sem effs () Source #
Add a requirement that the output format must satisfy.
writeTo :: Member FromPandoc effs => PandocWriteFormat a -> WriterOptions -> Pandoc -> Sem effs a Source #
Write given doc in requested format
toPandoc :: PandocMonad m => PandocReadFormat a -> ReaderOptions -> a -> m Pandoc Source #
Convert a to Pandoc with the given options
fromPandoc :: PandocMonad m => PandocWriteFormat a -> WriterOptions -> PandocWithRequirements -> m a Source #
Convert Pandoc to requested format with the given options. | Throw a PandocError if the output format is unsupported given the inputs.
Interpreters
runPandocWriter :: PandocEffects effs => Sem (ToPandoc ': effs) () -> Sem effs PandocWithRequirements Source #
Run ToPandoc by interpreting in Writer and then running that Writer.
Docs effect type-aliases
type Pandocs = Docs PandocWithRequirements Source #
Type-alias for use with the Docs
effect.
Data type to hold one named document of type a
.
Instances
Functor NamedDoc Source # | |
Foldable NamedDoc Source # | |
Defined in Knit.Effect.Docs fold :: Monoid m => NamedDoc m -> m # foldMap :: Monoid m => (a -> m) -> NamedDoc a -> m # foldr :: (a -> b -> b) -> b -> NamedDoc a -> b # foldr' :: (a -> b -> b) -> b -> NamedDoc a -> b # foldl :: (b -> a -> b) -> b -> NamedDoc a -> b # foldl' :: (b -> a -> b) -> b -> NamedDoc a -> b # foldr1 :: (a -> a -> a) -> NamedDoc a -> a # foldl1 :: (a -> a -> a) -> NamedDoc a -> a # elem :: Eq a => a -> NamedDoc a -> Bool # maximum :: Ord a => NamedDoc a -> a # minimum :: Ord a => NamedDoc a -> a # | |
Traversable NamedDoc Source # | |
Docs Effect Interpreters
:: (PandocEffects effs, Member Pandocs effs) | |
=> Text | name of document |
-> Sem (ToPandoc ': effs) () | |
-> Sem effs () |
Add the Pandoc stored in the writer-style ToPandoc effect to the named docs collection with the given name.
:: PandocEffects effs | |
=> PandocWriteFormat a | format for Pandoc output |
-> WriterOptions | options for the Pandoc Writer |
-> Sem (Pandocs ': effs) () | effects stack to be (partially) run to get documents |
-> Sem effs [NamedDoc a] | documents in requested format, within the effects monad |
Given a write format and options, convert a list of named Pandocs to a list of named docs in the requested format
:: PandocEffects effs | |
=> PandocWriteFormat a | format for Pandoc output |
-> WriterOptions | options for the Pandoc Writer |
-> Sem (ToPandoc ': effs) () | effects stack to be (partially) run to get document |
-> Sem effs a | document in requested format, within the effects monad |
Given a write format and options, run the writer-style ToPandoc effect and produce a doc of requested type