pandoc-pyplot 2.2.0.0 → 2.3.0.0
raw patch · 12 files changed
+137/−130 lines, 12 filesdep ~pandocdep ~pandoc-typessetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: pandoc, pandoc-types
API changes (from Hackage documentation)
- Text.Pandoc.Filter.Pyplot.Internal: saveFormatFromString :: String -> Maybe SaveFormat
- Text.Pandoc.Filter.Pyplot.Internal: FigureSpec :: String -> Bool -> PythonScript -> SaveFormat -> FilePath -> Int -> RenderingLibrary -> Bool -> Bool -> Attr -> FigureSpec
+ Text.Pandoc.Filter.Pyplot.Internal: FigureSpec :: Text -> Bool -> PythonScript -> SaveFormat -> FilePath -> Int -> RenderingLibrary -> Bool -> Bool -> Attr -> FigureSpec
- Text.Pandoc.Filter.Pyplot.Internal: [caption] :: FigureSpec -> String
+ Text.Pandoc.Filter.Pyplot.Internal: [caption] :: FigureSpec -> Text
- Text.Pandoc.Filter.Pyplot.Internal: captionKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: captionKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: directoryKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: directoryKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: dpiKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: dpiKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: includePathKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: includePathKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: inclusionKeys :: [String]
+ Text.Pandoc.Filter.Pyplot.Internal: inclusionKeys :: [Text]
- Text.Pandoc.Filter.Pyplot.Internal: isTightBboxKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: isTightBboxKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: isTransparentKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: isTransparentKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: saveFormatKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: saveFormatKey :: Text
- Text.Pandoc.Filter.Pyplot.Internal: withLinksKey :: String
+ Text.Pandoc.Filter.Pyplot.Internal: withLinksKey :: Text
Files
- CHANGELOG.md +6/−1
- README.md +0/−1
- Setup.hs +7/−7
- executable/ManPage.hs +2/−4
- pandoc-pyplot.cabal +4/−4
- src/Text/Pandoc/Filter/Pyplot.hs +3/−3
- src/Text/Pandoc/Filter/Pyplot/Configuration.hs +14/−14
- src/Text/Pandoc/Filter/Pyplot/FigureSpec.hs +43/−48
- src/Text/Pandoc/Filter/Pyplot/Scripting.hs +1/−1
- src/Text/Pandoc/Filter/Pyplot/Types.hs +37/−38
- stack.yaml +12/−1
- test/Main.hs +8/−8
CHANGELOG.md view
@@ -2,10 +2,15 @@ pandoc-pyplot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +Release 2.3.0.0 +--------------- + +* Added support for pandoc 2.8 and pandoc-types 1.20 (fixes #9). Because of breaking changes in pandoc-types 1.20, pandoc-pyplot 2.3.0.0+ only supports pandoc 2.8+. + Release 2.2.0.0 --------------- -* Added support for rendering figures via the Plotly library +* Added support for rendering figures via the Plotly library. Release 2.1.5.1 ---------------
README.md view
@@ -267,7 +267,6 @@ dpi: 80 tight_bbox: false transparent: false -flags: [] ``` Using `pandoc-pyplot --write-example-config` will write the default configuration to a file `.pandoc-pyplot.yml`, which you can then customize.
Setup.hs view
@@ -1,7 +1,7 @@--- This script is used to build and install your package. Typically you don't --- need to change it. The Cabal documentation has more information about this --- file: <https://www.haskell.org/cabal/users-guide/installing-packages.html>. -import qualified Distribution.Simple - -main :: IO () -main = Distribution.Simple.defaultMain +-- This script is used to build and install your package. Typically you don't+-- need to change it. The Cabal documentation has more information about this+-- file: <https://www.haskell.org/cabal/users-guide/installing-packages.html>.+import qualified Distribution.Simple++main :: IO ()+main = Distribution.Simple.defaultMain
executable/ManPage.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE OverloadedStrings #-} {-| This module was inspired by pandoc-crossref |-} @@ -45,7 +46,4 @@ embedManualHtml :: Q Exp embedManualHtml = do - t <- runIO $ fmap (either (error . show) id) $ P.runIO $ P.getDefaultTemplate "html5" - embedManual $ P.writeHtml5String P.def { P.writerTemplate = Just t - , P.writerHighlightStyle = Just pygments - } + embedManual $ P.writeHtml5String P.def { P.writerHighlightStyle = Just pygments }
pandoc-pyplot.cabal view
@@ -1,5 +1,5 @@ name: pandoc-pyplot -version: 2.2.0.0 +version: 2.3.0.0 cabal-version: >= 1.12 synopsis: A Pandoc filter to include figures generated from Python code blocks description: A Pandoc filter to include figures generated from Python code blocks. Keep the document and Python code in the same location. Output is captured and included as a figure. @@ -42,8 +42,8 @@ , data-default-class >= 0.1.2 , filepath >= 1.4 && < 2 , hashable >= 1 && < 2 - , pandoc >= 2 && < 3 - , pandoc-types >=1.12 && < 2 + , pandoc >= 2.8 && <3 + , pandoc-types >= 1.20 && < 1.30 , shakespeare >= 2.0 && < 3 , temporary , text >= 1 && < 2 @@ -70,7 +70,7 @@ , optparse-applicative >= 0.14 && < 1 , pandoc , pandoc-pyplot - , pandoc-types >1.12 && <2 + , pandoc-types , template-haskell > 2.7 && < 3 , temporary , text
src/Text/Pandoc/Filter/Pyplot.hs view
@@ -63,8 +63,8 @@ import Text.Pandoc.Filter.Pyplot.Internal --- | Main routine to include Matplotlib plots. --- Code blocks containing the attributes @.pyplot@ are considered +-- | Main routine to include plots. +-- Code blocks containing the attributes @.pyplot@ or @.plotly@ are considered -- Python plotting scripts. All other possible blocks are ignored. makePlot' :: Block -> PyplotM (Either PandocPyplotError Block) makePlot' block = do @@ -79,7 +79,7 @@ handleResult spec ScriptSuccess = Right $ toImage spec -- | Highest-level function that can be walked over a Pandoc tree. --- All code blocks that have the '.pyplot' parameter will be considered +-- All code blocks that have the @.pyplot@ / @.plotly@ class will be considered -- figures. makePlot :: Block -> IO Block makePlot = makePlotWithConfig def
src/Text/Pandoc/Filter/Pyplot/Configuration.hs view
@@ -27,8 +27,8 @@ import Data.Default.Class (def) import Data.Maybe (fromMaybe) -import qualified Data.Text as T -import qualified Data.Text.IO as T +import Data.String (fromString) +import qualified Data.Text.IO as TIO import Data.Yaml import Data.Yaml.Config (ignoreEnv, loadYamlSettings) @@ -61,23 +61,23 @@ instance FromJSON ConfigPrecursor where parseJSON (Object v) = ConfigPrecursor - <$> v .:? (T.pack directoryKey) .!= (defaultDirectory def) - <*> v .:? (T.pack includePathKey) - <*> v .:? (T.pack withLinksKey) .!= (defaultWithLinks def) - <*> v .:? (T.pack saveFormatKey) .!= (extension $ defaultSaveFormat def) - <*> v .:? (T.pack dpiKey) .!= (defaultDPI def) - <*> v .:? (T.pack isTightBboxKey) .!= (isTightBbox def) - <*> v .:? (T.pack isTransparentKey) .!= (isTransparent def) - <*> v .:? "interpreter" .!= (interpreter def) - <*> v .:? "flags" .!= (flags def) + <$> v .:? directoryKey .!= (defaultDirectory def) + <*> v .:? includePathKey + <*> v .:? withLinksKey .!= (defaultWithLinks def) + <*> v .:? saveFormatKey .!= (show $ defaultSaveFormat def) + <*> v .:? dpiKey .!= (defaultDPI def) + <*> v .:? isTightBboxKey .!= (isTightBbox def) + <*> v .:? isTransparentKey .!= (isTransparent def) + <*> v .:? "interpreter" .!= (interpreter def) + <*> v .:? "flags" .!= (flags def) parseJSON _ = fail "Could not parse the configuration" - + renderConfiguration :: ConfigPrecursor -> IO Configuration renderConfiguration prec = do - includeScript <- fromMaybe mempty $ T.readFile <$> defaultIncludePath_ prec - let saveFormat' = fromMaybe (defaultSaveFormat def) $ saveFormatFromString $ defaultSaveFormat_ prec + includeScript <- fromMaybe mempty $ TIO.readFile <$> defaultIncludePath_ prec + let saveFormat' = fromString $ defaultSaveFormat_ prec return $ Configuration { defaultDirectory = defaultDirectory_ prec , defaultIncludeScript = includeScript
src/Text/Pandoc/Filter/Pyplot/FigureSpec.hs view
@@ -1,8 +1,6 @@-{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeSynonymInstances #-} - +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE TemplateHaskell #-} {-| Module : $header$ Copyright : (c) Laurent P René de Cotret, 2019 @@ -17,7 +15,6 @@ module Text.Pandoc.Filter.Pyplot.FigureSpec ( FigureSpec(..) , SaveFormat(..) - , saveFormatFromString , toImage , sourceCodePath , figurePath @@ -29,7 +26,7 @@ import Control.Monad (join) import Control.Monad.IO.Class (liftIO) -import Control.Monad.Reader +import Control.Monad.Reader (ask) import Data.Default.Class (def) import Data.Hashable (hash) @@ -37,8 +34,9 @@ import qualified Data.Map.Strict as Map import Data.Maybe (fromMaybe) import Data.Monoid ((<>)) -import qualified Data.Text as T -import qualified Data.Text.IO as T +import Data.String (fromString) +import Data.Text (Text, pack, unpack) +import qualified Data.Text.IO as TIO import Data.Version (showVersion) import Paths_pandoc_pyplot (version) @@ -49,7 +47,8 @@ import Text.Pandoc.Builder (fromList, imageWith, link, para, toList) -import Text.Pandoc.Definition +import Text.Pandoc.Definition (Block (..), Inline, + Pandoc (..)) import Text.Shakespeare.Text (st) import Text.Pandoc.Class (runPure) @@ -61,7 +60,7 @@ import Text.Pandoc.Filter.Pyplot.Types --- | Determine inclusion specifications from Block attributes. +-- | Determine inclusion specifications from @Block@ attributes. -- Note that the @".pyplot"@ OR @.plotly@ class is required, but all other -- parameters are optional. parseFigureSpec :: Block -> PyplotM (Maybe FigureSpec) @@ -72,42 +71,37 @@ where attrs' = Map.fromList attrs filteredAttrs = filter (\(k, _) -> k `notElem` inclusionKeys) attrs - includePath = Map.lookup includePathKey attrs' + includePath = unpack <$> Map.lookup includePathKey attrs' + header = "# Generated by pandoc-pyplot " <> ((pack . showVersion) version) figureSpec :: RenderingLibrary -> PyplotM FigureSpec figureSpec lib = do config <- ask includeScript <- fromMaybe (return $ defaultIncludeScript config) - ((liftIO . T.readFile) <$> includePath) - let header = "# Generated by pandoc-pyplot " <> ((T.pack . showVersion) version) - fullScript = mconcat $ intersperse "\n" [header, includeScript, T.pack content] - caption' = Map.findWithDefault mempty captionKey attrs' - format = fromMaybe (defaultSaveFormat config) $ join $ saveFormatFromString <$> Map.lookup saveFormatKey attrs' - dir = makeValid $ Map.findWithDefault (defaultDirectory config) directoryKey attrs' - dpi' = fromMaybe (defaultDPI config) $ read <$> Map.lookup dpiKey attrs' - withLinks' = fromMaybe (defaultWithLinks config) $ readBool <$> Map.lookup withLinksKey attrs' - tightBbox' = isTightBbox config - transparent' = isTransparent config - blockAttrs' = (id', filter (\c -> c `notElem` ["pyplot", "plotly"]) cls, filteredAttrs) - return $ FigureSpec - caption' - withLinks' - fullScript - format - dir - dpi' - lib - tightBbox' - transparent' - blockAttrs' + ((liftIO . TIO.readFile) <$> includePath) + return $ + FigureSpec + { caption = Map.findWithDefault mempty captionKey attrs' + , withLinks = fromMaybe (defaultWithLinks config) $ readBool <$> Map.lookup withLinksKey attrs' + , script = mconcat $ intersperse "\n" [header, includeScript, content] + , saveFormat = fromMaybe (defaultSaveFormat config) $ (fromString . unpack) <$> Map.lookup saveFormatKey attrs' + , directory = makeValid $ unpack $ Map.findWithDefault (pack $ defaultDirectory config) directoryKey attrs' + , dpi = fromMaybe (defaultDPI config) $ (read . unpack) <$> Map.lookup dpiKey attrs' + , renderingLib = lib + , tightBbox = isTightBbox config + , transparent = isTransparent config + , blockAttrs = (id', filter (\c -> c `notElem` ["pyplot", "plotly"]) cls, filteredAttrs) + } parseFigureSpec _ = return Nothing --- | Convert a FigureSpec to a Pandoc block component +-- | Convert a @FigureSpec@ to a Pandoc block component. +-- Note that the script to generate figure files must still +-- be run in another function. toImage :: FigureSpec -> Block -toImage spec = head . toList $ para $ imageWith attrs' target' "fig:" caption' +toImage spec = head . toList $ para $ imageWith attrs' (pack target') "fig:" caption' -- To render images as figures with captions, the target title -- must be "fig:" -- Janky? yes @@ -115,8 +109,8 @@ attrs' = blockAttrs spec target' = figurePath spec withLinks' = withLinks spec - srcLink = link (replaceExtension target' ".txt") mempty "Source code" - hiresLink = link (hiresFigurePath spec) mempty "high res." + srcLink = link (pack $ replaceExtension target' ".txt") mempty "Source code" + hiresLink = link (pack $ hiresFigurePath spec) mempty "high res." captionText = fromList $ fromMaybe mempty (captionReader $ caption spec) captionLinks = mconcat [" (", srcLink, ", ", hiresLink, ")"] caption' = if withLinks' then captionText <> captionLinks else captionText @@ -155,16 +149,17 @@ , plotCapture (renderingLib spec) (hiresFigurePath spec) (minimum [200, 2 * dpi spec]) False (tight') ] where - tight' = if tightBbox spec then ("'tight'" :: T.Text) else ("None" :: T.Text) + tight' = if tightBbox spec then ("'tight'" :: Text) else ("None" :: Text) -- Note that, especially for Windows, raw strings (r"...") must be used because path separators might -- be interpreted as escape characters plotCapture Matplotlib = captureMatplotlib plotCapture Plotly = capturePlotly -type Tight = T.Text +type Tight = Text +type DPI = Int type IsTransparent = Bool -type RenderingFunc = (FilePath -> Int -> IsTransparent -> Tight -> PythonScript) +type RenderingFunc = (FilePath -> DPI -> IsTransparent -> Tight -> PythonScript) -- | Capture plot from Matplotlib @@ -176,14 +171,14 @@ plt.savefig(r"#{fname'}", dpi=#{dpi'}, transparent=#{transparent''}, bbox_inches=#{tight'}) |] where - transparent'' :: T.Text + transparent'' :: Text transparent'' = if transparent' then "True" else "False" -- | Capture Plotly figure -- --- We are trying to emulate the behavior of "matplotlib.pyplot.savefig" which +-- We are trying to emulate the behavior of @matplotlib.pyplot.savefig@ which -- knows the "current figure". This saves us from contraining users to always --- have the same Plotly figure name, e.g. "fig" in all examples +-- have the same Plotly figure name, e.g. @fig@ in all examples on plot.ly capturePlotly :: RenderingFunc capturePlotly fname' _ _ _ = [st| import plotly.graph_objects as go @@ -207,8 +202,8 @@ -- | Read a figure caption in Markdown format. LaTeX math @$...$@ is supported, -- as are Markdown subscripts and superscripts. -captionReader :: String -> Maybe [Inline] -captionReader t = either (const Nothing) (Just . extractFromBlocks) $ runPure $ readMarkdown' (T.pack t) +captionReader :: Text -> Maybe [Inline] +captionReader t = either (const Nothing) (Just . extractFromBlocks) $ runPure $ readMarkdown' t where readMarkdown' = readMarkdown readerOptions @@ -221,7 +216,7 @@ -- | Flexible boolean parsing -readBool :: String -> Bool +readBool :: Text -> Bool readBool s | s `elem` ["True", "true", "'True'", "'true'", "1"] = True | s `elem` ["False", "false", "'False'", "'false'", "0"] = False - | otherwise = error $ mconcat ["Could not parse '", s, "' into a boolean. Please use 'True' or 'False'"] + | otherwise = error $ unpack $ mconcat ["Could not parse '", s, "' into a boolean. Please use 'True' or 'False'"]
src/Text/Pandoc/Filter/Pyplot/Scripting.hs view
@@ -80,7 +80,7 @@ checkResult = mconcat $ scriptChecks <*> [script'] hashedPath = show . hash $ script' - + -- | Run the Python script. In case the file already exists, we can safely assume -- there is no need to re-run it. runScriptIfNecessary :: FigureSpec
src/Text/Pandoc/Filter/Pyplot/Types.hs view
@@ -19,9 +19,11 @@ import Data.Char (toLower) import Data.Default.Class (Default, def) import Data.Hashable (Hashable) +import Data.List (intersperse) import Data.Semigroup as Sem -import Data.Text (Text, pack) -import Data.Yaml +import Data.String (IsString(..)) +import Data.Text (Text) +import Data.Yaml (ToJSON, object, toJSON, (.=)) import GHC.Generics (Generic) @@ -29,7 +31,7 @@ -- | Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes. -directoryKey, captionKey, dpiKey, includePathKey, saveFormatKey, withLinksKey, isTightBboxKey, isTransparentKey :: String +directoryKey, captionKey, dpiKey, includePathKey, saveFormatKey, withLinksKey, isTightBboxKey, isTransparentKey :: Text directoryKey = "directory" captionKey = "caption" dpiKey = "dpi" @@ -42,7 +44,7 @@ -- | list of all keys related to pandoc-pyplot that -- can be specified in source material. -inclusionKeys :: [String] +inclusionKeys :: [Text] inclusionKeys = [ directoryKey , captionKey , dpiKey @@ -123,28 +125,25 @@ | TIF deriving (Bounded, Enum, Eq, Show, Generic) -instance Hashable SaveFormat -- From Generic +instance IsString SaveFormat where + -- | An error is thrown if the save format cannot be parsed. + fromString s + | s `elem` ["png", "PNG", ".png"] = PNG + | s `elem` ["pdf", "PDF", ".pdf"] = PDF + | s `elem` ["svg", "SVG", ".svg"] = SVG + | s `elem` ["eps", "EPS", ".eps"] = EPS + | s `elem` ["gif", "GIF", ".gif"] = GIF + | s `elem` ["jpg", "jpeg", "JPG", "JPEG", ".jpg", ".jpeg"] = JPG + | s `elem` ["tif", "tiff", "TIF", "TIFF", ".tif", ".tiff"] = TIF + | otherwise = error $ + mconcat [ s + , " is not one of valid save format : " + , mconcat $ intersperse ", " $ show <$> saveFormats + ] + where + saveFormats = (enumFromTo minBound maxBound) :: [SaveFormat] --- | Parse an image save format string --- --- >>> saveFormatFromString ".png" --- Just PNG --- --- >>> saveFormatFromString "jpeg" --- Just JPEG --- --- >>> SaveFormatFromString "arbitrary" --- Nothing -saveFormatFromString :: String -> Maybe SaveFormat -saveFormatFromString s - | s `elem` ["png", "PNG", ".png"] = Just PNG - | s `elem` ["pdf", "PDF", ".pdf"] = Just PDF - | s `elem` ["svg", "SVG", ".svg"] = Just SVG - | s `elem` ["eps", "EPS", ".eps"] = Just EPS - | s `elem` ["gif", "GIF", ".gif"] = Just GIF - | s `elem` ["jpg", "jpeg", "JPG", "JPEG", ".jpg", ".jpeg"] = Just JPG - | s `elem` ["tif", "tiff", "TIF", "TIFF", ".tif", ".tiff"] = Just TIF - | otherwise = Nothing +instance Hashable SaveFormat -- From Generic -- | Save format file extension extension :: SaveFormat -> String @@ -199,15 +198,15 @@ toJSON (Configuration dir' _ withLinks' savefmt' dpi' tightbbox' transparent' interp' flags') = -- We ignore the include script as we want to examplify that -- this is for a filepath - object [ pack directoryKey .= dir' - , pack includePathKey .= ("example.py" :: FilePath) - , pack withLinksKey .= withLinks' - , pack dpiKey .= dpi' - , pack saveFormatKey .= (toLower <$> show savefmt') - , pack isTightBboxKey .= tightbbox' - , pack isTransparentKey .= transparent' - , "interpreter" .= interp' - , "flags" .= flags' + object [ directoryKey .= dir' + , includePathKey .= ("example.py" :: FilePath) + , withLinksKey .= withLinks' + , dpiKey .= dpi' + , saveFormatKey .= (fmap toLower . show $ savefmt') + , isTightBboxKey .= tightbbox' + , isTransparentKey .= transparent' + , "interpreter" .= interp' + , "flags" .= flags' ] @@ -216,15 +215,15 @@ -- 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 - { caption :: String -- ^ Figure caption. + { caption :: Text -- ^ Figure caption. , withLinks :: Bool -- ^ Append links to source code and high-dpi figure to caption. , script :: PythonScript -- ^ Source code for the figure. , saveFormat :: SaveFormat -- ^ Save format of the figure. , directory :: FilePath -- ^ Directory where to save the file. - , dpi :: Int -- ^ Dots-per-inch of figure. This option only affects the Matplotlib backend. + , dpi :: Int -- ^ Dots-per-inch of figure. , renderingLib :: RenderingLibrary -- ^ Rendering library. - , tightBbox :: Bool -- ^ Enforce tight bounding-box with @bbox_inches="tight"@. This option only affects the Matplotlib backend. - , transparent :: Bool -- ^ Make figure background transparent. This option only affects the Matplotlib backend. + , tightBbox :: Bool -- ^ Enforce tight bounding-box with @bbox_inches="tight"@. + , transparent :: Bool -- ^ Make figure background transparent. , blockAttrs :: Attr -- ^ Attributes not related to @pandoc-pyplot@ will be propagated. } deriving Generic
stack.yaml view
@@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-14.1 +resolver: lts-14.16 # User packages to be built. # Various formats can be used as shown in the example below. @@ -38,6 +38,17 @@ # using the same syntax as the packages field. # (e.g., acme-missiles-0.3) extra-deps: +- pandoc-2.8 +- pandoc-types-1.20@sha256:8393b1a73b8a6a1f3feaeb3a6592c176461082c3e4d897f1b316b1a58dd84c39,3999 +- texmath-0.12 +- HsYAML-0.2.1.0@sha256:e4677daeba57f7a1e9a709a1f3022fe937336c91513e893166bd1f023f530d68,5311 +- doclayout-0.2.0.1@sha256:0410e40c4fa8e299b4f5fa03d378111b9d0effdf59134c95882a160637887ba8,2063 +- doctemplates-0.7.2@sha256:e9a3a2182446f6f4548096d1349088144c349c504675660ab30e432af3136bda,3113 +- haddock-library-1.8.0@sha256:9dece2cbca827755fdfc30af5a407b0ca30cf29ec1ee85215b38fd8fc23e7421,3723 +- skylighting-0.8.2.3@sha256:8155893fe493dbd64367573f6f87338375f50f7003a8cc7ef8ae3836aea52a29,9730 +- skylighting-core-0.8.2.3@sha256:3de402288d8748a334461a73bbbbdc0bc92a8533c983bfaeb7017d4653e283e6,8058 +- regex-pcre-builtin-0.95.1.1.8.43@sha256:2d671af361adf1776fde182a687bb6da022b1e5e3b0a064ce264289de63564a5,3088 +- regex-base-0.94.0.0@sha256:d514eab2aa9ba4b9d14900ac40cbdea1993372466a6cc6ffeeab59a1975563c0,2166 # Override default flag values for local packages and extra-deps # flags: {}
test/Main.hs view
@@ -9,7 +9,7 @@ import Data.Default.Class (def) import Data.List (isInfixOf, isSuffixOf) import Data.Monoid ((<>)) -import Data.Text (unpack) +import Data.Text (unpack, pack) import Test.Tasty import Test.Tasty.HUnit @@ -48,31 +48,31 @@ ] plotCodeBlock :: PythonScript -> Block -plotCodeBlock script = CodeBlock (mempty, ["pyplot"], mempty) (unpack script) +plotCodeBlock script = CodeBlock (mempty, ["pyplot"], mempty) script addCaption :: String -> Block -> Block addCaption caption (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(captionKey, caption)]) script + CodeBlock (id', cls, attrs ++ [(captionKey, pack caption)]) script addDirectory :: FilePath -> Block -> Block addDirectory dir (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(directoryKey, dir)]) script + CodeBlock (id', cls, attrs ++ [(directoryKey, pack dir)]) script addInclusion :: FilePath -> Block -> Block addInclusion inclusionPath (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(includePathKey, inclusionPath)]) script + CodeBlock (id', cls, attrs ++ [(includePathKey, pack inclusionPath)]) script addSaveFormat :: SaveFormat -> Block -> Block addSaveFormat saveFormat (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(saveFormatKey, extension saveFormat)]) script + CodeBlock (id', cls, attrs ++ [(saveFormatKey, pack . extension $ saveFormat)]) script addDPI :: Int -> Block -> Block addDPI dpi (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(dpiKey, show dpi)]) script + CodeBlock (id', cls, attrs ++ [(dpiKey, pack . show $ dpi)]) script addWithLinks :: Bool -> Block -> Block addWithLinks yn (CodeBlock (id', cls, attrs) script) = - CodeBlock (id', cls, attrs ++ [(withLinksKey, show yn)]) script + CodeBlock (id', cls, attrs ++ [(withLinksKey, pack . show $ yn)]) script -- | Assert that a file exists