Skip to content

Commit

Permalink
Fixed an issue where tight_bbox was ignored for the Matplotlib toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed May 13, 2022
1 parent f0af92a commit 933daba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion pandoc-plot.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Text/Pandoc/Filter/Plot/Renderers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Filter/Plot/Renderers/Matplotlib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 933daba

Please sign in to comment.