-- 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.2.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 data Configuration Configuration :: !FilePath -> !Bool -> !Int -> !SaveFormat -> !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. Default preambles [defaultSaveFormat] :: Configuration -> !SaveFormat [matplotlibPreamble] :: Configuration -> !Script [plotlyPythonPreamble] :: Configuration -> !Script [matlabPreamble] :: Configuration -> !Script [mathematicaPreamble] :: Configuration -> !Script [octavePreamble] :: Configuration -> !Script [ggplot2Preamble] :: Configuration -> !Script [gnuplotPreamble] :: Configuration -> !Script [matplotlibExe] :: Configuration -> !FilePath [matlabExe] :: Configuration -> !FilePath [plotlyPythonExe] :: Configuration -> !FilePath [mathematicaExe] :: Configuration -> !FilePath [octaveExe] :: Configuration -> !FilePath [ggplot2Exe] :: Configuration -> !FilePath [gnuplotExe] :: Configuration -> !FilePath [matplotlibTightBBox] :: Configuration -> !Bool [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 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: all -- formats are supported by Matplotlib, but not all formats are supported -- by Plotly 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. For example: -- --