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

Copyright(c) Laurent P René de Cotret 2019
LicenseMIT
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 :: [String] Source #

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

directoryKey :: String Source #

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

captionKey :: String Source #

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

dpiKey :: String Source #

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

includePathKey :: String Source #

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

saveFormatKey :: String Source #

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

withLinksKey :: String Source #

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

isTightBboxKey :: String Source #

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

isTransparentKey :: String 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.

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

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.1.5.1-GB7WNPx3JqVG8LPAZgN71Q" 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))))

saveFormatFromString :: String -> Maybe SaveFormat Source #

Parse an image save format string

>>> saveFormatFromString ".png"
Just PNG
>>> saveFormatFromString "jpeg"
Just JPEG
>>> SaveFormatFromString "arbitrary"
Nothing

toImage :: FigureSpec -> Block Source #

Convert a FigureSpec to a Pandoc block component

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 :: Configuration -> Block -> IO (Maybe FigureSpec) Source #

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

extension :: SaveFormat -> String Source #

Save format file extension

runTempPythonScript Source #

Arguments

:: String

Interpreter (e.g. "python" or "python35")

-> [String]

Command-line flags

-> PythonScript

Content of the script

-> IO ScriptResult

Result.

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

runScriptIfNecessary :: Configuration -> FigureSpec -> IO 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 :: String Source #

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

captionKey :: String Source #

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

dpiKey :: String Source #

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

includePathKey :: String Source #

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

saveFormatKey :: String Source #

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

withLinksKey :: String Source #

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

isTightBboxKey :: String Source #

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

isTransparentKey :: String Source #

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

inclusionKeys :: [String] Source #

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

type PythonScript = Text Source #

String representation of a Python script

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.

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

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.1.5.1-GB7WNPx3JqVG8LPAZgN71Q" 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))))

saveFormatFromString :: String -> Maybe SaveFormat Source #

Parse an image save format string

>>> saveFormatFromString ".png"
Just PNG
>>> saveFormatFromString "jpeg"
Just JPEG
>>> SaveFormatFromString "arbitrary"
Nothing

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

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