Copyright | (c) Laurent P René de Cotret 2020 |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | laurent.decotret@outlook.com |
Stability | internal |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module re-exports internal pandoc-plot functionality. The external use of content from this module is discouraged.
Synopsis
- data Toolkit
- type PlotM a = ReaderT PlotEnv IO a
- data PlotEnv = PlotEnv {
- toolkit :: !Toolkit
- config :: !Configuration
- data Configuration = Configuration {
- defaultDirectory :: !FilePath
- defaultWithSource :: !Bool
- defaultDPI :: !Int
- defaultSaveFormat :: !SaveFormat
- captionFormat :: !Format
- matplotlibPreamble :: !Script
- plotlyPythonPreamble :: !Script
- plotlyRPreamble :: !Script
- matlabPreamble :: !Script
- mathematicaPreamble :: !Script
- octavePreamble :: !Script
- ggplot2Preamble :: !Script
- gnuplotPreamble :: !Script
- graphvizPreamble :: !Script
- matplotlibExe :: !FilePath
- matlabExe :: !FilePath
- plotlyPythonExe :: !FilePath
- plotlyRExe :: !FilePath
- mathematicaExe :: !FilePath
- octaveExe :: !FilePath
- ggplot2Exe :: !FilePath
- gnuplotExe :: !FilePath
- graphvizExe :: !FilePath
- matplotlibTightBBox :: !Bool
- matplotlibTransparent :: !Bool
- type Script = Text
- data CheckResult
- data InclusionKey
- data FigureSpec = FigureSpec {
- caption :: !Text
- withSource :: !Bool
- script :: !Script
- saveFormat :: !SaveFormat
- directory :: !FilePath
- dpi :: !Int
- extraAttrs :: ![(Text, Text)]
- blockAttrs :: !Attr
- data SaveFormat
- figureContentHash :: FigureSpec -> Int
- cls :: Toolkit -> Text
- extension :: SaveFormat -> String
- toolkits :: [Toolkit]
- inclusionKeys :: [InclusionKey]
- isWindows :: Bool
- scriptExtension :: Toolkit -> String
- comment :: Toolkit -> Text -> Text
- preambleSelector :: Toolkit -> Configuration -> Script
- supportedSaveFormats :: Toolkit -> [SaveFormat]
- scriptChecks :: Toolkit -> [Script -> CheckResult]
- parseExtraAttrs :: Toolkit -> Map Text Text -> Map Text Text
- command :: Toolkit -> OutputSpec -> IO Text
- capture :: Toolkit -> FigureSpec -> FilePath -> Script
- executable :: Toolkit -> Configuration -> IO FilePath
- toolkitAvailable :: Toolkit -> Configuration -> IO Bool
- availableToolkits :: Configuration -> IO [Toolkit]
- unavailableToolkits :: Configuration -> IO [Toolkit]
- data OutputSpec = OutputSpec {}
- data ScriptResult
- runTempScript :: FigureSpec -> PlotM ScriptResult
- runScriptIfNecessary :: FigureSpec -> PlotM ScriptResult
- toImage :: Format -> FigureSpec -> Block
- plotToolkit :: Block -> Maybe Toolkit
- parseFigureSpec :: Block -> PlotM (Maybe FigureSpec)
- captionReader :: Format -> Text -> Maybe [Inline]
- configuration :: FilePath -> IO Configuration
- configurationPathMeta :: Pandoc -> Maybe FilePath
- defaultConfiguration :: Configuration
- cleanOutputDirs :: Walkable Block b => Configuration -> b -> IO [FilePath]
- readDoc :: FilePath -> IO Pandoc
Documentation
Enumeration of supported toolkits
Instances
Bounded Toolkit Source # | |
Enum Toolkit Source # | |
Eq Toolkit Source # | |
Show Toolkit Source # | This instance should only be used to display toolkit names |
Generic Toolkit Source # | |
type Rep Toolkit Source # | |
Defined in Text.Pandoc.Filter.Plot.Types type Rep Toolkit = D1 (MetaData "Toolkit" "Text.Pandoc.Filter.Plot.Types" "pandoc-plot-0.6.0.0-8E8gm0do5Mp1YT6dYBbPxl" False) (((C1 (MetaCons "Matplotlib" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Matlab" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "PlotlyPython" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "PlotlyR" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "Mathematica" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Octave" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "GGPlot2" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "GNUPlot" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Graphviz" PrefixI False) (U1 :: Type -> Type))))) |
data Configuration Source #
The Configuration
type holds the default values to use
when running pandoc-plot. These values can be overridden in code blocks.
You can create an instance of the Configuration
type from file using the configuration
function.
You can store the path to a configuration file in metadata under the key plot-configuration
. For example, in Markdown:
--- title: My document author: John Doe plot-configuration: pathto/file.yml ---
The same can be specified via the command line using Pandoc's -M
flag:
pandoc --filter pandoc-plot -M plot-configuration="path/to/file.yml" ...
In this case, use configurationPathMeta
to extact the path from Pandoc
documents.
Configuration | |
|
Instances
Eq Configuration Source # | |
Defined in Text.Pandoc.Filter.Plot.Types (==) :: Configuration -> Configuration -> Bool # (/=) :: Configuration -> Configuration -> Bool # | |
Show Configuration Source # | |
Defined in Text.Pandoc.Filter.Plot.Types showsPrec :: Int -> Configuration -> ShowS # show :: Configuration -> String # showList :: [Configuration] -> ShowS # | |
Default Configuration Source # | |
Defined in Text.Pandoc.Filter.Plot.Types def :: Configuration # |
data CheckResult Source #
Result of checking scripts for problems
Instances
Eq CheckResult Source # | |
Defined in Text.Pandoc.Filter.Plot.Types (==) :: CheckResult -> CheckResult -> Bool # (/=) :: CheckResult -> CheckResult -> Bool # | |
Semigroup CheckResult Source # | |
Defined in Text.Pandoc.Filter.Plot.Types (<>) :: CheckResult -> CheckResult -> CheckResult # sconcat :: NonEmpty CheckResult -> CheckResult # stimes :: Integral b => b -> CheckResult -> CheckResult # | |
Monoid CheckResult Source # | |
Defined in Text.Pandoc.Filter.Plot.Types mempty :: CheckResult # mappend :: CheckResult -> CheckResult -> CheckResult # mconcat :: [CheckResult] -> CheckResult # |
data InclusionKey Source #
Description of any possible inclusion key, both in documents and in configuration files.
DirectoryK | |
CaptionK | |
SaveFormatK | |
WithSourceK | |
CaptionFormatK | |
PreambleK | |
DpiK | |
ExecutableK | |
MatplotlibTightBBoxK | |
MatplotlibTransparentK |
Instances
Bounded InclusionKey Source # | |
Defined in Text.Pandoc.Filter.Plot.Types | |
Enum InclusionKey Source # | |
Defined in Text.Pandoc.Filter.Plot.Types succ :: InclusionKey -> InclusionKey # pred :: InclusionKey -> InclusionKey # toEnum :: Int -> InclusionKey # fromEnum :: InclusionKey -> Int # enumFrom :: InclusionKey -> [InclusionKey] # enumFromThen :: InclusionKey -> InclusionKey -> [InclusionKey] # enumFromTo :: InclusionKey -> InclusionKey -> [InclusionKey] # enumFromThenTo :: InclusionKey -> InclusionKey -> InclusionKey -> [InclusionKey] # | |
Eq InclusionKey Source # | |
Defined in Text.Pandoc.Filter.Plot.Types (==) :: InclusionKey -> InclusionKey -> Bool # (/=) :: InclusionKey -> InclusionKey -> Bool # | |
Show InclusionKey Source # | Keys that pandoc-plot will look for in code blocks. These are only exported for testing purposes. |
Defined in Text.Pandoc.Filter.Plot.Types showsPrec :: Int -> InclusionKey -> ShowS # show :: InclusionKey -> String # showList :: [InclusionKey] -> ShowS # |
data FigureSpec Source #
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.
FigureSpec | |
|
data SaveFormat Source #
Generated figure file format supported by pandoc-plot. Note that not all formats are supported by all toolkits.
Instances
figureContentHash :: FigureSpec -> Int Source #
Hash of the content of a FigureSpec
. Note that unlike usual hashes,
two FigureSpec
with the same figureContentHash
does not mean that they are equal!
Not all parts of a FigureSpec are related to running code. For example, changing the caption should not require running the figure again.
extension :: SaveFormat -> String Source #
Save format file extension
inclusionKeys :: [InclusionKey] Source #
List of all keys related to pandoc-plot that can be specified in source material.
scriptExtension :: Toolkit -> String Source #
preambleSelector :: Toolkit -> Configuration -> Script Source #
The function that maps from configuration to the preamble.
supportedSaveFormats :: Toolkit -> [SaveFormat] Source #
Save formats supported by this renderer.
scriptChecks :: Toolkit -> [Script -> CheckResult] Source #
parseExtraAttrs :: Toolkit -> Map Text Text -> Map Text Text Source #
Parse code block headers for extra attributes that are specific to this renderer. By default, no extra attributes are parsed.
command :: Toolkit -> OutputSpec -> IO Text Source #
Generate the appropriate command-line command to generate a figure. The executable will need to be found first, hence the IO monad.
capture :: Toolkit -> FigureSpec -> FilePath -> Script Source #
Script fragment required to capture a figure.
executable :: Toolkit -> Configuration -> IO FilePath Source #
Path to the executable of a toolkit. If the executable can be found, then it will be the full path to it.
toolkitAvailable :: Toolkit -> Configuration -> IO Bool Source #
Check if a toolkit is available, based on the current configuration
availableToolkits :: Configuration -> IO [Toolkit] Source #
List of toolkits available on this machine. The executables to look for are taken from the configuration.
unavailableToolkits :: Configuration -> IO [Toolkit] Source #
List of toolkits not available on this machine. The executables to look for are taken from the configuration.
data OutputSpec Source #
Internal description of all information needed to output a figure.
OutputSpec | |
|
data ScriptResult Source #
Possible result of running a script
:: Format | text format of the caption |
-> FigureSpec | |
-> Block |
Convert a FigureSpec
to a Pandoc block component.
Note that the script to generate figure files must still
be run in another function.
plotToolkit :: Block -> Maybe Toolkit Source #
Determine which toolkit should be used to render the plot from a code block, if any.
parseFigureSpec :: Block -> PlotM (Maybe FigureSpec) Source #
Determine inclusion specifications from Block
attributes.
If an environment is detected, but the save format is incompatible,
an error will be thrown.
captionReader :: Format -> Text -> Maybe [Inline] Source #
Reader a caption, based on input document format
configuration :: FilePath -> IO Configuration Source #
Read configuration from a YAML file. The keys are exactly the same as for code blocks.
If a key is not present, its value will be set to the default value. Parsing errors result in thrown exceptions.
configurationPathMeta :: Pandoc -> Maybe FilePath Source #
Extact path to configuration from the metadata in a Pandoc document.
The path to the configuration file should be under the plot-configuration
key.
In case there is no such metadata, return the default configuration.
For example, at the top of a markdown file:
--- title: My document author: John Doe plot-configuration: pathto/file.yml ---
The same can be specified via the command line using Pandoc's -M
flag:
pandoc --filter pandoc-plot -M plot-configuration="path/to/file.yml" ...
Since: 0.6.0.0
defaultConfiguration :: Configuration Source #
Default configuration values.
Since: 0.5.0.0
cleanOutputDirs :: Walkable Block b => Configuration -> b -> IO [FilePath] Source #
Clean all output related to pandoc-plot. This includes output directories specified in the configuration and in the document/block. Note that *all* files in pandoc-plot output directories will be removed.
The cleaned directories are returned.