pandoc-pyplot-2.3.0.1: A Pandoc filter to include figures generated from Python code blocks

Copyright(c) Laurent P René de Cotret 2019
LicenseGNU GPL, version 2 or above
Maintainerlaurent.decotret@outlook.com
Stabilityinternal
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.Pandoc.Filter.Pyplot.Internal

Contents

Description

This module re-exports internal pandoc-pyplot functionality.

Synopsis

Documentation

configuration :: FilePath -> IO Configuration Source #

Building configuration from a YAML file. The keys are exactly the same as for Markdown code blocks.

If a key is either not present or unreadable, its value will be set to the default value.

Since: 2.1.0.0

For testing and internal purposes only

writeConfig :: FilePath -> Configuration -> IO () Source #

Write a configuration to file. An exception will be raised in case the file would be overwritten.

Since: 2.1.3.0

inclusionKeys :: [Text] Source #

list of all keys related to pandoc-pyplot that can be specified in source material.

directoryKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

captionKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

dpiKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

includePathKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

saveFormatKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

withLinksKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

isTightBboxKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

isTransparentKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

data FigureSpec Source #

Datatype containing all parameters required to run pandoc-pyplot.

It is assumed that once a FigureSpec has been created, no configuration can overload it; hence, a FigureSpec completely encodes a particular figure.

Constructors

FigureSpec 

Fields

Instances
Generic FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Associated Types

type Rep FigureSpec :: Type -> Type #

Hashable FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

data SaveFormat Source #

Generated figure file format supported by pandoc-pyplot. Note: all formats are supported by Matplotlib, but not all formats are supported by Plotly

Constructors

PNG 
PDF 
SVG 
JPG 
EPS 
GIF 
TIF 
Instances
Bounded SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Enum SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Eq SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Show SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

IsString SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Generic SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Associated Types

type Rep SaveFormat :: Type -> Type #

Hashable SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep SaveFormat = D1 (MetaData "SaveFormat" "Text.Pandoc.Filter.Pyplot.Types" "pandoc-pyplot-2.3.0.1-IGrvRP9DaEZGihWZD1Kmym" False) ((C1 (MetaCons "PNG" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "PDF" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "SVG" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "JPG" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "EPS" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "GIF" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TIF" PrefixI False) (U1 :: Type -> Type))))

toImage :: FigureSpec -> Block Source #

Convert a FigureSpec to a Pandoc block component. Note that the script to generate figure files must still be run in another function.

sourceCodePath :: FigureSpec -> FilePath Source #

Determine the path to the source code that generated the figure.

figurePath :: FigureSpec -> FilePath Source #

Determine the path a figure should have.

addPlotCapture Source #

Arguments

:: FigureSpec

Path where to save the figure

-> PythonScript

Code block with added capture

Modify a Python plotting script to save the figure to a filename. An additional file will also be captured.

parseFigureSpec :: Block -> PyplotM (Maybe FigureSpec) Source #

Determine inclusion specifications from Block attributes. Note that the ".pyplot" OR .plotly class is required, but all other parameters are optional.

extension :: SaveFormat -> String Source #

Save format file extension

runTempPythonScript Source #

Arguments

:: PythonScript

Content of the script

-> PyplotM ScriptResult

Result.

Take a python script in string form, write it in a temporary directory, then execute it.

runScriptIfNecessary :: FigureSpec -> PyplotM ScriptResult Source #

Run the Python script. In case the file already exists, we can safely assume there is no need to re-run it.

directoryKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

captionKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

dpiKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

includePathKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

saveFormatKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

withLinksKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

isTightBboxKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

isTransparentKey :: Text Source #

Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.

inclusionKeys :: [Text] Source #

list of all keys related to pandoc-pyplot that can be specified in source material.

type PyplotM a = ReaderT Configuration IO a Source #

Monad in which to run pandoc-pyplot computations

type PythonScript = Text Source #

String representation of a Python script

data RenderingLibrary Source #

Rendering library

Since: 2.2.0.0

Constructors

Matplotlib

Rendering via the Matplotlib library. This library has the most features.

Plotly

Rendering via the Plotly library.

Instances
Eq RenderingLibrary Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Show RenderingLibrary Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Generic RenderingLibrary Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Associated Types

type Rep RenderingLibrary :: Type -> Type #

Hashable RenderingLibrary Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep RenderingLibrary Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep RenderingLibrary = D1 (MetaData "RenderingLibrary" "Text.Pandoc.Filter.Pyplot.Types" "pandoc-pyplot-2.3.0.1-IGrvRP9DaEZGihWZD1Kmym" False) (C1 (MetaCons "Matplotlib" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Plotly" PrefixI False) (U1 :: Type -> Type))

data ScriptResult Source #

Possible result of running a Python script

data PandocPyplotError Source #

Possible errors returned by the filter

Constructors

ScriptError Int

Running Python script has yielded an error

ScriptChecksFailedError String

Python script did not pass all checks

data SaveFormat Source #

Generated figure file format supported by pandoc-pyplot. Note: all formats are supported by Matplotlib, but not all formats are supported by Plotly

Constructors

PNG 
PDF 
SVG 
JPG 
EPS 
GIF 
TIF 
Instances
Bounded SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Enum SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Eq SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Show SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

IsString SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Generic SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Associated Types

type Rep SaveFormat :: Type -> Type #

Hashable SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep SaveFormat Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep SaveFormat = D1 (MetaData "SaveFormat" "Text.Pandoc.Filter.Pyplot.Types" "pandoc-pyplot-2.3.0.1-IGrvRP9DaEZGihWZD1Kmym" False) ((C1 (MetaCons "PNG" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "PDF" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "SVG" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "JPG" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "EPS" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "GIF" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TIF" PrefixI False) (U1 :: Type -> Type))))

extension :: SaveFormat -> String Source #

Save format file extension

defaultPlatformInterpreter :: String Source #

Default interpreter should be Python 3, which has a different name on Windows ("python") vs Unix ("python3")

Since: 2.1.2.0

data Configuration Source #

Configuration of pandoc-pyplot, describing the default behavior of the filter.

A Configuration is useful when dealing with lots of figures; it avoids repeating the same values.sta

Since: 2.1.0.0

Constructors

Configuration 

Fields

  • defaultDirectory :: FilePath

    The default directory where figures will be saved.

  • defaultIncludeScript :: PythonScript

    The default script to run before other instructions.

  • defaultWithLinks :: Bool

    The default behavior of whether or not to include links to source code and high-res

  • defaultSaveFormat :: SaveFormat

    The default save format of generated figures.

  • defaultDPI :: Int

    The default dots-per-inch value for generated figures. Matplotlib only, ignored otherwise.

  • isTightBbox :: Bool

    Whether the figures should be saved with bbox_inches="tight" or not. Useful for larger figures with subplots. Matplotlib only, ignored otherwise.

  • isTransparent :: Bool

    If True, figures will be saved with transparent background rather than solid color. .Matplotlib only, ignored otherwise.

  • interpreter :: String

    The name of the interpreter to use to render figures.

  • flags :: [String]

    Command-line flags to be passed to the Python interpreger, e.g. ["-O", "-Wignore"]

data FigureSpec Source #

Datatype containing all parameters required to run pandoc-pyplot.

It is assumed that once a FigureSpec has been created, no configuration can overload it; hence, a FigureSpec completely encodes a particular figure.

Constructors

FigureSpec 

Fields

Instances
Generic FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

Associated Types

type Rep FigureSpec :: Type -> Type #

Hashable FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

type Rep FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types