Skip to content

Commit 933daba

Browse files
committed
Fixed an issue where tight_bbox was ignored for the Matplotlib toolkit
1 parent f0af92a commit 933daba

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
44

5+
## Release 1.5.3
6+
7+
* Fixed an issue where the `tight_bbox` option for Matplotlib plots was ignored (#48)
8+
59
## Release 1.5.2
610

711
* Overhauled the way executables are handled. This fixes an issue where executables specified in documents (rather than configuration) were ignored (#46).

pandoc-plot.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: pandoc-plot
3-
version: 1.5.2
3+
version: 1.5.3
44
synopsis: A Pandoc filter to include figures generated from code blocks using your plotting toolkit of choice.
55
description: A Pandoc filter to include figures generated from code blocks.
66
Keep the document and code in the same location. Output is

src/Text/Pandoc/Filter/Plot/Renderers.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ preambleSelector SageMath = sagemathPreamble
120120
-- | Parse code block headers for extra attributes that are specific
121121
-- to this renderer. By default, no extra attributes are parsed.
122122
parseExtraAttrs :: Toolkit -> Map Text Text -> Map Text Text
123-
parseExtraAttrs Matplotlib = M.filterWithKey (\k _ -> k `elem` ["tight_bbox", "transparent"])
123+
parseExtraAttrs Matplotlib = M.filterWithKey (\k _ -> k `elem` [ pack $ show MatplotlibTightBBoxK
124+
, pack $ show MatplotlibTransparentK
125+
])
124126
parseExtraAttrs _ = return mempty
125127

126128
-- | List of toolkits available on this machine.

src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ plt.savefig(r"#{fname}", dpi=#{dpi}, transparent=#{transparent}, bbox_inches=#{t
6060
|]
6161
where
6262
attrs = M.fromList extraAttrs
63-
tight_ = readBool $ M.findWithDefault "False" "tight" attrs
64-
transparent_ = readBool $ M.findWithDefault "False" "transparent" attrs
63+
tight_ = readBool $ M.findWithDefault "False" (T.pack $ show MatplotlibTightBBoxK) attrs
64+
transparent_ = readBool $ M.findWithDefault "False" (T.pack $ show MatplotlibTransparentK) attrs
6565
tightBox = if tight_ then ("'tight'" :: Text) else ("None" :: Text)
6666
transparent = if transparent_ then ("True" :: Text) else ("False" :: Text)
6767

0 commit comments

Comments
 (0)