-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Pandoc filter for including figures generated from Matplotlib -- -- A pandoc filter for including figures generated from Matplotlib. Keep -- the document and Python code in the same location. Output from -- Matplotlib is captured and included as a figure. @package pandoc-pyplot @version 2.0.0.0 -- | This module defines types and functions that help with running Python -- scripts. module Text.Pandoc.Filter.Scripting -- | Take a python script in string form, write it in a temporary -- directory, then execute it. runTempPythonScript :: PythonScript -> IO ScriptResult -- | Detect the presence of a blocking show call, for example "plt.show()" hasBlockingShowCall :: PythonScript -> Bool -- | String representation of a Python script type PythonScript = Text -- | Possible result of running a Python script data ScriptResult ScriptSuccess :: ScriptResult ScriptFailure :: Int -> ScriptResult -- | This module defines types and functions that help with keeping track -- of figure specifications module Text.Pandoc.Filter.FigureSpec -- | Datatype containing all parameters required to run pandoc-pyplot data FigureSpec FigureSpec :: String -> PythonScript -> SaveFormat -> FilePath -> Int -> Attr -> FigureSpec -- | Figure caption. [caption] :: FigureSpec -> String -- | Source code for the figure. [script] :: FigureSpec -> PythonScript -- | Save format of the figure [saveFormat] :: FigureSpec -> SaveFormat -- | Directory where to save the file [directory] :: FigureSpec -> FilePath -- | Dots-per-inch of figure [dpi] :: FigureSpec -> Int -- | Attributes not related to pandoc-pyplot will be propagated. [blockAttrs] :: FigureSpec -> Attr data SaveFormat PNG :: SaveFormat PDF :: SaveFormat SVG :: SaveFormat JPG :: SaveFormat EPS :: SaveFormat -- | Parse an image save format string saveFormatFromString :: String -> Maybe SaveFormat -- | Determine the path a figure should have. figurePath :: FigureSpec -> FilePath -- | The path to the high-resolution figure. hiresFigurePath :: FigureSpec -> FilePath -- | Modify a Python plotting script to save the figure to a filename. An -- additional file (with extension PNG) will also be captured. addPlotCapture :: FigureSpec -> PythonScript -- | Save format file extension extension :: SaveFormat -> String instance Data.Hashable.Class.Hashable Text.Pandoc.Filter.FigureSpec.FigureSpec -- | This module defines a Pandoc filter makePlot that can be used -- to walk over a Pandoc document and generate figures from Python code -- blocks. -- -- The syntax for code blocks is simple, Code blocks with the -- .pyplot attribute will trigger the filter. The code block -- will be reworked into a Python script and the output figure will be -- captured, along with a high-resolution version of the figure and the -- source code used to generate the figure. -- -- To trigger pandoc-pyplot, the following is required: -- --
-- This is a paragraph
--
-- ```{.pyplot caption="This is a caption."}
-- import matplotlib.pyplot as plt
--
-- plt.figure()
-- plt.plot([0,1,2,3,4], [1,2,3,4,5])
-- plt.title('This is an example figure')
-- ```
--
--
-- This filter was originally designed to be used with Hakyll. In
-- case you want to use the filter with your own Hakyll setup, you can
-- use a transform function that works on entire documents:
--
-- -- import Text.Pandoc.Filter.Pyplot (plotTransform) -- -- import Hakyll -- -- -- Unsafe compiler is required because of the interaction -- -- in IO (i.e. running an external Python script). -- makePlotPandocCompiler :: Compiler (Item String) -- makePlotPandocCompiler = -- pandocCompilerWithTransformM -- defaultHakyllReaderOptions -- defaultHakyllWriterOptions -- (unsafeCompiler . plotTransform) --module Text.Pandoc.Filter.Pyplot -- | Highest-level function that can be walked over a Pandoc tree. All code -- blocks that have the '.pyplot' parameter will be considered figures. makePlot :: Block -> IO Block -- | Walk over an entire Pandoc document, changing appropriate code blocks -- into figures. plotTransform :: Pandoc -> IO Pandoc -- | Possible errors returned by the filter data PandocPyplotError -- | Running Python script has yielded an error ScriptError :: Int -> PandocPyplotError -- | Invalid figure path InvalidTargetError :: FilePath -> PandocPyplotError -- | Python script contains a block call to 'show()' BlockingCallError :: PandocPyplotError -- | Main routine to include Matplotlib plots. Code blocks containing the -- attributes .pyplot are considered Python plotting scripts. -- All other possible blocks are ignored. makePlot' :: Block -> IO (Either PandocPyplotError Block) -- | Keys that pandoc-pyplot will look for in code blocks. These are only -- exported for testing purposes. directoryKey :: String -- | Keys that pandoc-pyplot will look for in code blocks. These are only -- exported for testing purposes. captionKey :: String -- | Keys that pandoc-pyplot will look for in code blocks. These are only -- exported for testing purposes. dpiKey :: String -- | Keys that pandoc-pyplot will look for in code blocks. These are only -- exported for testing purposes. includePathKey :: String -- | Keys that pandoc-pyplot will look for in code blocks. These are only -- exported for testing purposes. saveFormatKey :: String instance GHC.Classes.Eq Text.Pandoc.Filter.Pyplot.PandocPyplotError instance GHC.Show.Show Text.Pandoc.Filter.Pyplot.PandocPyplotError