-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Pandoc filter to include figures generated from code blocks using your plotting toolkit of choice. -- -- A Pandoc filter to include figures generated from code blocks. Keep -- the document and code in the same location. Output is captured and -- included as a figure. @package pandoc-plot @version 0.3.0.0 -- | This module re-exports internal pandoc-plot functionality. The -- external use of content from this module is discouraged. module Text.Pandoc.Filter.Plot.Internal -- | Enumeration of supported toolkits data Toolkit Matplotlib :: Toolkit Matlab :: Toolkit PlotlyPython :: Toolkit Mathematica :: Toolkit Octave :: Toolkit GGPlot2 :: Toolkit GNUPlot :: Toolkit type PlotM a = ReaderT PlotEnv IO a data PlotEnv PlotEnv :: !Toolkit -> !Configuration -> PlotEnv [toolkit] :: PlotEnv -> !Toolkit [config] :: PlotEnv -> !Configuration -- | The Configuration type holds the default values to use when -- running pandoc-plot. These values can be overridden in code blocks. data Configuration Configuration :: !FilePath -> !Bool -> !Int -> !SaveFormat -> Format -> !Script -> !Script -> !Script -> !Script -> !Script -> !Script -> !Script -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !Bool -> !Bool -> Configuration -- | The default directory where figures will be saved. [defaultDirectory] :: Configuration -> !FilePath -- | The default behavior of whether or not to include links to source code -- and high-res [defaultWithSource] :: Configuration -> !Bool -- | The default dots-per-inch value for generated figures. Renderers might -- ignore this. [defaultDPI] :: Configuration -> !Int -- | The default save format of generated figures. [defaultSaveFormat] :: Configuration -> !SaveFormat -- | Caption format, in the same notation as Pandoc format, e.g. -- "markdown+tex_math_dollars" [captionFormat] :: Configuration -> Format -- | The default preamble script for the matplotlib toolkit. [matplotlibPreamble] :: Configuration -> !Script -- | The default preamble script for the Plotly/Python toolkit. [plotlyPythonPreamble] :: Configuration -> !Script -- | The default preamble script for the MATLAB toolkit. [matlabPreamble] :: Configuration -> !Script -- | The default preamble script for the Mathematica toolkit. [mathematicaPreamble] :: Configuration -> !Script -- | The default preamble script for the GNU Octave toolkit. [octavePreamble] :: Configuration -> !Script -- | The default preamble script for the GGPlot2 toolkit. [ggplot2Preamble] :: Configuration -> !Script -- | The default preamble script for the gnuplot toolkit. [gnuplotPreamble] :: Configuration -> !Script -- | The executable to use to generate figures using the matplotlib -- toolkit. [matplotlibExe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the MATLAB toolkit. [matlabExe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the Plotly/Python -- toolkit. [plotlyPythonExe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the Mathematica -- toolkit. [mathematicaExe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the GNU Octave -- toolkit. [octaveExe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the GGPlot2 toolkit. [ggplot2Exe] :: Configuration -> !FilePath -- | The executable to use to generate figures using the gnuplot toolkit. [gnuplotExe] :: Configuration -> !FilePath -- | Whether or not to make Matplotlib figures tight by default. [matplotlibTightBBox] :: Configuration -> !Bool -- | Whether or not to make Matplotlib figures transparent by default. [matplotlibTransparent] :: Configuration -> !Bool type Script = Text -- | Result of checking scripts for problems data CheckResult CheckPassed :: CheckResult CheckFailed :: String -> CheckResult -- | Description of any possible inclusion key, both in documents and in -- configuration files. data InclusionKey DirectoryK :: InclusionKey CaptionK :: InclusionKey SaveFormatK :: InclusionKey WithSourceK :: InclusionKey CaptionFormatK :: InclusionKey PreambleK :: InclusionKey DpiK :: InclusionKey ExecutableK :: InclusionKey MatplotlibTightBBoxK :: InclusionKey MatplotlibTransparentK :: InclusionKey -- | Datatype containing all parameters required to run pandoc-plot. -- -- It is assumed that once a FigureSpec has been created, no -- configuration can overload it; hence, a FigureSpec completely -- encodes a particular figure. data FigureSpec FigureSpec :: !Text -> !Bool -> !Script -> !SaveFormat -> !FilePath -> !Int -> ![(Text, Text)] -> !Attr -> FigureSpec -- | Figure caption. [caption] :: FigureSpec -> !Text -- | Append link to source code in caption. [withSource] :: FigureSpec -> !Bool -- | Source code for the figure. [script] :: FigureSpec -> !Script -- | 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 -- | Renderer-specific extra attributes. [extraAttrs] :: FigureSpec -> ![(Text, Text)] -- | Attributes not related to pandoc-plot will be propagated. [blockAttrs] :: FigureSpec -> !Attr -- | Generated figure file format supported by pandoc-plot. Note that not -- all formats are supported by all toolkits. data SaveFormat PNG :: SaveFormat PDF :: SaveFormat SVG :: SaveFormat JPG :: SaveFormat EPS :: SaveFormat GIF :: SaveFormat TIF :: SaveFormat WEBP :: SaveFormat -- | Class name which will trigger the filter cls :: Toolkit -> Text -- | Save format file extension extension :: SaveFormat -> String toolkits :: [Toolkit] -- | List of all keys related to pandoc-plot that can be specified in -- source material. inclusionKeys :: [InclusionKey] isWindows :: Bool scriptExtension :: Toolkit -> String comment :: Toolkit -> Text -> Text -- | The function that maps from configuration to the preamble. preambleSelector :: Toolkit -> Configuration -> Script -- | Save formats supported by this renderer. supportedSaveFormats :: Toolkit -> [SaveFormat] scriptChecks :: Toolkit -> [Script -> CheckResult] -- | Parse code block headers for extra attributes that are specific to -- this renderer. By default, no extra attributes are parsed. parseExtraAttrs :: Toolkit -> Map Text Text -> Map Text Text -- | Generate the appropriate command-line command to generate a figure. command :: Toolkit -> Configuration -> FigureSpec -> FilePath -> Text -- | Script fragment required to capture a figure. capture :: Toolkit -> FigureSpec -> FilePath -> Script -- | List of toolkits available on this machine. The executables to look -- for are taken from the configuration. availableToolkits :: Configuration -> IO [Toolkit] -- | List of toolkits not available on this machine. The executables to -- look for are taken from the configuration. unavailableToolkits :: Configuration -> IO [Toolkit] -- | Possible result of running a script data ScriptResult ScriptSuccess :: ScriptResult ScriptChecksFailed :: String -> ScriptResult ScriptFailure :: String -> Int -> ScriptResult runTempScript :: FigureSpec -> PlotM ScriptResult runScriptIfNecessary :: FigureSpec -> PlotM ScriptResult -- | Convert a FigureSpec to a Pandoc block component. Note that -- the script to generate figure files must still be run in another -- function. toImage :: Format -> FigureSpec -> Block -- | Determine which toolkit should be used to render the plot from a code -- block, if any. plotToolkit :: Block -> Maybe Toolkit -- | Determine inclusion specifications from Block attributes. If -- an environment is detected, but the save format is incompatible, an -- error will be thrown. parseFigureSpec :: Block -> PlotM (Maybe FigureSpec) -- | Reader a caption, based on input document format captionReader :: Format -> Text -> Maybe [Inline] -- | Read configuration from a YAML file. The keys are exactly the same as -- for code blocks. -- -- If a key is either not present, its value will be set to the default -- value. Parsing errors result in thrown exceptions. configuration :: FilePath -> IO Configuration -- | This module defines a Pandoc filter makePlot and related -- functions that can be used to walk over a Pandoc document and generate -- figures from code blocks using a multitude of plotting toolkits. -- -- The syntax for code blocks is simple, Code blocks with the appropriate -- class attribute will trigger the filter: -- --
-- ```{.gnuplot format=png caption="Sinusoidal function"}
-- sin(x)
--
-- set xlabel "x"
-- set ylabel "y"
-- ```
--
module Text.Pandoc.Filter.Plot
-- | Highest-level function that can be walked over a Pandoc tree. All code
-- blocks that have the .plot / .plotly class will be
-- considered figures.
--
-- The target document format determines how the figure captions should
-- be parsed. By default (i.e. if Nothing), captions will be parsed as
-- Markdown with LaTeX math $...$,
makePlot :: Configuration -> Block -> IO Block
-- | Walk over an entire Pandoc document, changing appropriate code blocks
-- into figures. Default configuration is used.
plotTransform :: Configuration -> Pandoc -> IO Pandoc
-- | Read configuration from a YAML file. The keys are exactly the same as
-- for code blocks.
--
-- If a key is either not present, its value will be set to the default
-- value. Parsing errors result in thrown exceptions.
configuration :: FilePath -> IO Configuration
-- | The Configuration type holds the default values to use when
-- running pandoc-plot. These values can be overridden in code blocks.
data Configuration
Configuration :: !FilePath -> !Bool -> !Int -> !SaveFormat -> Format -> !Script -> !Script -> !Script -> !Script -> !Script -> !Script -> !Script -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !FilePath -> !Bool -> !Bool -> Configuration
-- | The default directory where figures will be saved.
[defaultDirectory] :: Configuration -> !FilePath
-- | The default behavior of whether or not to include links to source code
-- and high-res
[defaultWithSource] :: Configuration -> !Bool
-- | The default dots-per-inch value for generated figures. Renderers might
-- ignore this.
[defaultDPI] :: Configuration -> !Int
-- | The default save format of generated figures.
[defaultSaveFormat] :: Configuration -> !SaveFormat
-- | Caption format, in the same notation as Pandoc format, e.g.
-- "markdown+tex_math_dollars"
[captionFormat] :: Configuration -> Format
-- | The default preamble script for the matplotlib toolkit.
[matplotlibPreamble] :: Configuration -> !Script
-- | The default preamble script for the Plotly/Python toolkit.
[plotlyPythonPreamble] :: Configuration -> !Script
-- | The default preamble script for the MATLAB toolkit.
[matlabPreamble] :: Configuration -> !Script
-- | The default preamble script for the Mathematica toolkit.
[mathematicaPreamble] :: Configuration -> !Script
-- | The default preamble script for the GNU Octave toolkit.
[octavePreamble] :: Configuration -> !Script
-- | The default preamble script for the GGPlot2 toolkit.
[ggplot2Preamble] :: Configuration -> !Script
-- | The default preamble script for the gnuplot toolkit.
[gnuplotPreamble] :: Configuration -> !Script
-- | The executable to use to generate figures using the matplotlib
-- toolkit.
[matplotlibExe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the MATLAB toolkit.
[matlabExe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the Plotly/Python
-- toolkit.
[plotlyPythonExe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the Mathematica
-- toolkit.
[mathematicaExe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the GNU Octave
-- toolkit.
[octaveExe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the GGPlot2 toolkit.
[ggplot2Exe] :: Configuration -> !FilePath
-- | The executable to use to generate figures using the gnuplot toolkit.
[gnuplotExe] :: Configuration -> !FilePath
-- | Whether or not to make Matplotlib figures tight by default.
[matplotlibTightBBox] :: Configuration -> !Bool
-- | Whether or not to make Matplotlib figures transparent by default.
[matplotlibTransparent] :: Configuration -> !Bool
-- | Generated figure file format supported by pandoc-plot. Note that not
-- all formats are supported by all toolkits.
data SaveFormat
PNG :: SaveFormat
PDF :: SaveFormat
SVG :: SaveFormat
JPG :: SaveFormat
EPS :: SaveFormat
GIF :: SaveFormat
TIF :: SaveFormat
WEBP :: SaveFormat
type Script = Text
-- | Force to use a particular toolkit to render appropriate code blocks.
--
-- Failing to render a figure does not stop the filter, so that you may
-- run the filter on documents without having all necessary toolkits
-- installed. In this case, error messages are printed to stderr, and
-- blocks are left unchanged.
make :: Toolkit -> Configuration -> Block -> IO Block
-- | List of toolkits available on this machine. The executables to look
-- for are taken from the configuration.
availableToolkits :: Configuration -> IO [Toolkit]
-- | List of toolkits not available on this machine. The executables to
-- look for are taken from the configuration.
unavailableToolkits :: Configuration -> IO [Toolkit]
instance GHC.Classes.Eq Text.Pandoc.Filter.Plot.PandocPlotError
instance GHC.Show.Show Text.Pandoc.Filter.Plot.PandocPlotError