summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent René de Cotret <l.rdc@socivolta.com>2022-05-13 13:06:16 -0400
committerLaurent René de Cotret <l.rdc@socivolta.com>2022-05-13 13:06:16 -0400
commit933daba593196bf3b1ae1f2022d17389552f275c (patch)
treeabf8974d0c67c8fda2e62f1fbf5bb1b025167e02
parentf0af92a8b215477cb379d5cc00316b65b6d80114 (diff)
Fixed an issue where `tight_bbox` was ignored for the Matplotlib toolkit1.5.3
-rw-r--r--CHANGELOG.md4
-rw-r--r--pandoc-plot.cabal2
-rw-r--r--src/Text/Pandoc/Filter/Plot/Renderers.hs4
-rw-r--r--src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs4
4 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 987f608..fb3441c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
+## Release 1.5.3
+
+* Fixed an issue where the `tight_bbox` option for Matplotlib plots was ignored (#48)
+
## Release 1.5.2
* Overhauled the way executables are handled. This fixes an issue where executables specified in documents (rather than configuration) were ignored (#46).
diff --git a/pandoc-plot.cabal b/pandoc-plot.cabal
index a9ce005..319ad79 100644
--- a/pandoc-plot.cabal
+++ b/pandoc-plot.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: pandoc-plot
-version: 1.5.2
+version: 1.5.3
synopsis: A Pandoc filter to include figures generated from code blocks using your plotting toolkit of choice.
description: A Pandoc filter to include figures generated from code blocks.
Keep the document and code in the same location. Output is
diff --git a/src/Text/Pandoc/Filter/Plot/Renderers.hs b/src/Text/Pandoc/Filter/Plot/Renderers.hs
index 8824afe..9d83d9f 100644
--- a/src/Text/Pandoc/Filter/Plot/Renderers.hs
+++ b/src/Text/Pandoc/Filter/Plot/Renderers.hs
@@ -120,7 +120,9 @@ preambleSelector SageMath = sagemathPreamble
-- | Parse code block headers for extra attributes that are specific
-- to this renderer. By default, no extra attributes are parsed.
parseExtraAttrs :: Toolkit -> Map Text Text -> Map Text Text
-parseExtraAttrs Matplotlib = M.filterWithKey (\k _ -> k `elem` ["tight_bbox", "transparent"])
+parseExtraAttrs Matplotlib = M.filterWithKey (\k _ -> k `elem` [ pack $ show MatplotlibTightBBoxK
+ , pack $ show MatplotlibTransparentK
+ ])
parseExtraAttrs _ = return mempty
-- | List of toolkits available on this machine.
diff --git a/src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs b/src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs
index 3588c9d..9890ab6 100644
--- a/src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs
+++ b/src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs
@@ -60,8 +60,8 @@ plt.savefig(r"#{fname}", dpi=#{dpi}, transparent=#{transparent}, bbox_inches=#{t
|]
where
attrs = M.fromList extraAttrs
- tight_ = readBool $ M.findWithDefault "False" "tight" attrs
- transparent_ = readBool $ M.findWithDefault "False" "transparent" attrs
+ tight_ = readBool $ M.findWithDefault "False" (T.pack $ show MatplotlibTightBBoxK) attrs
+ transparent_ = readBool $ M.findWithDefault "False" (T.pack $ show MatplotlibTransparentK) attrs
tightBox = if tight_ then ("'tight'" :: Text) else ("None" :: Text)
transparent = if transparent_ then ("True" :: Text) else ("False" :: Text)