mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-22 23:45:48 +00:00
[API Change] Export new module Text.Pandoc.Scripting
The module contains the central data structure for scripting engines.
This commit is contained in:
committed by
John MacFarlane
parent
ddaadc88bc
commit
704f337697
@@ -651,6 +651,7 @@ library
|
||||
Text.Pandoc.Lua,
|
||||
Text.Pandoc.PDF,
|
||||
Text.Pandoc.UTF8,
|
||||
Text.Pandoc.Scripting,
|
||||
Text.Pandoc.Templates,
|
||||
Text.Pandoc.XML,
|
||||
Text.Pandoc.SelfContained,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ImpredicativeTypes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{- |
|
||||
Module : Text.Pandoc.Scripting
|
||||
Copyright : © 2022 Albert Krewinkel
|
||||
License : GPL-2.0-or-later
|
||||
Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
|
||||
|
||||
Central data structure for scripting engines.
|
||||
-}
|
||||
module Text.Pandoc.Scripting
|
||||
( ScriptingEngine (..)
|
||||
, noEngine
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import Data.Text (Text)
|
||||
import Text.Pandoc.Definition (Pandoc)
|
||||
import Text.Pandoc.Class.PandocMonad (PandocMonad)
|
||||
import Text.Pandoc.Filter.Environment (Environment)
|
||||
import Text.Pandoc.Options (ReaderOptions, WriterOptions)
|
||||
import Text.Pandoc.Sources (Sources)
|
||||
|
||||
-- | Structure to define a scripting engine.
|
||||
data ScriptingEngine = ScriptingEngine
|
||||
{ engineName :: Text -- ^ Name of the engine.
|
||||
|
||||
, engineApplyFilter :: forall m. (PandocMonad m, MonadIO m)
|
||||
=> Environment -> [String] -> FilePath
|
||||
-> Pandoc -> m Pandoc
|
||||
-- ^ Use the scripting engine to run a filter.
|
||||
|
||||
, engineReadCustom :: forall m. (PandocMonad m, MonadIO m)
|
||||
=> FilePath -> ReaderOptions -> Sources -> m Pandoc
|
||||
-- ^ Function to parse input into a 'Pandoc' document.
|
||||
|
||||
, engineWriteCustom :: forall m. (PandocMonad m, MonadIO m)
|
||||
=> FilePath -> WriterOptions -> Pandoc -> m Text
|
||||
-- ^ Invoke the given script file to convert to any custom format.
|
||||
}
|
||||
|
||||
noEngine :: ScriptingEngine
|
||||
noEngine = ScriptingEngine
|
||||
{ engineName = "none"
|
||||
, engineApplyFilter = \_env _args _fp _doc ->
|
||||
error "Custom filters are not supported."
|
||||
, engineReadCustom = \_fp _ropts _sources ->
|
||||
error "Custom readers are not supported."
|
||||
, engineWriteCustom = \_fp _wopts _doc ->
|
||||
error "Custom writers are not supported."
|
||||
}
|
||||
Reference in New Issue
Block a user