Skip to content

Commit

Permalink
Fixed an issue where TeX output contained a figure even if the captio…
Browse files Browse the repository at this point in the history
…n was empty
  • Loading branch information
LaurentRDC committed Sep 27, 2024
1 parent 58c901f commit a125b56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 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.9.2

* Fixed an issue where TeX output contained a figure even if the caption was empty (#37).

## Release 1.9.1

* Fixed an issue where extra parameters were not passed down to `pandoc`, depending on the output format (#38).
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.9.1
version: 1.9.2
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
14 changes: 9 additions & 5 deletions src/Text/Pandoc/Filter/Plot/Embed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ figure ::
PlotM Block
figure as fp caption' =
return . head . toList $

Check warning on line 84 in src/Text/Pandoc/Filter/Plot/Embed.hs

View workflow job for this annotation

GitHub Actions / build-and-test (windows-latest, 9.8.2)

In the use of ‘head’

Check warning on line 84 in src/Text/Pandoc/Filter/Plot/Embed.hs

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest, 9.8.2)

In the use of ‘head’

Check warning on line 84 in src/Text/Pandoc/Filter/Plot/Embed.hs

View workflow job for this annotation

GitHub Actions / build-and-test (macos-latest, 9.8.2)

In the use of ‘head’
-- We want the attributes both on the Figure element and the contained Image element
-- so that pandoc-plot plays nice with pandoc-crossref and other filters
figureWith as (simpleCaption (plain caption')) $
plain $
imageWith as (pack fp) mempty caption'
if null caption'
-- If there is no caption, a LaTeX figure may look strange. See #37
then plain $ imageWith as (pack fp) mempty caption'
else
-- We want the attributes both on the Figure element and the contained Image element
-- so that pandoc-plot plays nice with pandoc-crossref and other filters
figureWith as (simpleCaption (plain caption')) $
plain $
imageWith as (pack fp) mempty caption'

-- TODO: also add the case where SVG plots can be
-- embedded in HTML output
Expand Down

0 comments on commit a125b56

Please sign in to comment.