Copyright | (c) Laurent P René de Cotret 2018 |
---|---|
License | MIT |
Maintainer | laurent.decotret@outlook.com |
Stability | stable |
Portability | portable |
Safe Haskell | Unsafe |
Language | Haskell2010 |
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 plot_target=...
attribute will trigger the filter. The code block will be reworked into a Python
script and the output figure will be captured.
Here are the possible attributes what pandoc-pyplot understands:
plot_target=...
(_required_): Filepath where the resulting figure should be saved.plot_alt="..."
(_optional_): Specify a plot caption (or alternate text).plot_include=...
(_optional_): Path to a Python script to include before the code block. Ideal to avoid repetition over many figures.
Here are some example blocks in Markdown:
This is a paragraph ```{plot_target=my_figure.jpg plot_alt="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') ```
Synopsis
Documentation
makePlot :: Block -> IO Block Source #
Highest-level function that can be walked over a Pandoc tree.
All code blocks that have the plot_target
parameter will be considered
figures.
makePlot' :: Block -> IO (Either PandocPyplotError Block) Source #
Main routine to include Matplotlib plots.
Code blocks containing the attributes plot_target
are considered
Python plotting scripts. All other possible blocks are ignored.
The source code is also saved in another file, which can be access by
clicking the image
plotTransform :: Pandoc -> IO Pandoc Source #
Walk over an entire Pandoc document, changing appropriate code blocks into figures.
data PandocPyplotError Source #
Possible errors returned by the filter
ScriptError Int | Running Python script has yielded an error |
InvalidTargetError FilePath | Invalid figure path |
MissingDirectoryError FilePath | Directory where to save figure does not exist |
BlockingCallError | Python script contains a block call to 'show()' |
Instances
Eq PandocPyplotError Source # | |
Defined in Text.Pandoc.Filter.Pyplot (==) :: PandocPyplotError -> PandocPyplotError -> Bool # (/=) :: PandocPyplotError -> PandocPyplotError -> Bool # | |
Show PandocPyplotError Source # | |
Defined in Text.Pandoc.Filter.Pyplot showsPrec :: Int -> PandocPyplotError -> ShowS # show :: PandocPyplotError -> String # showList :: [PandocPyplotError] -> ShowS # |