pandoc-pyplot-2.1.3.0: 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.

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.

data FigureSpec Source #

Datatype containing all parameters required to run pandoc-pyplot

Constructors

FigureSpec 

Fields

Instances
Hashable FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types

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.

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.

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

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

Constructors

FigureSpec 

Fields

Instances
Hashable FigureSpec Source # 
Instance details

Defined in Text.Pandoc.Filter.Pyplot.Types