pandoc-plot 1.6.0 → 1.6.1
raw patch · 5 files changed
+44/−4 lines, 5 filesdep ~mtldep ~unixPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mtl, unix
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- pandoc-plot.cabal +3/−2
- src/Text/Pandoc/Filter/Plot/Embed.hs +7/−2
- tests/Common.hs +29/−0
- tests/Main.hs +1/−0
CHANGELOG.md view
@@ -2,6 +2,10 @@ pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +## Release 1.6.1++* Fixed an issue where figure attributes were lost, which prevent other filters (e.g. pandoc-crossref) from working in conjunction with pandoc-plot.+ ## Release 1.6.0 * Support for pandoc 3. Support for older pandoc version has also been dropped (pandoc 2.19 and earlier).
pandoc-plot.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: pandoc-plot-version: 1.6.0+version: 1.6.1 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 @@ -18,7 +18,8 @@ GHC == 9.0.1, GHC == 9.0.1, GHC == 9.2.1, - GHC == 9.2.2+ GHC == 9.2.2,+ GHC == 9.4.4 extra-source-files: CHANGELOG.md LICENSE
src/Text/Pandoc/Filter/Plot/Embed.hs view
@@ -33,9 +33,12 @@ import Text.Pandoc.Builder as Builder ( Inlines, fromList,- simpleFigureWith,+ figureWith,+ imageWith,+ plain, link, str,+ simpleCaption, toList, ) import Text.Pandoc.Class (runPure)@@ -79,7 +82,9 @@ PlotM Block figure as fp caption' = return . head . toList $- simpleFigureWith as caption' (pack fp) mempty+ -- 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 mempty (pack fp) mempty caption' -- TODO: also add the case where SVG plots can be -- embedded in HTML output
tests/Common.hs view
@@ -341,6 +341,32 @@ assertBool "" (expectedCheck result) assertChecksFail _ = assertEqual "Test skipped" True True +-------------------------------------------------------------------------------+-- Test that Markdown bold formatting in captions is correctly rendered+testAttributesPreservedOnFigure :: Toolkit -> TestTree+testAttributesPreservedOnFigure tk =+ testCase "preserves code block attributes and sets them on the Figure element" $ do+ let postfix = unpack . cls $ tk+ tempDir <- (</> "test-preserved-attrs-" <> postfix) <$> getTemporaryDirectory+ ensureDirectoryExistsAndEmpty tempDir++ -- Note that this test is fragile, in the sense that the expected result must be carefully+ -- constructed+ let expectedAttrs = ("hello", [cls tk], [("key1", "val1"), ("key2", "val2")])+ cb = setAttrs expectedAttrs $+ addDirectory tempDir $+ addCaption "[title](https://google.com)" $+ codeBlock tk (trivialContent tk)+ fmt = B.Format "markdown"+ Figure (id', _, keyvals) _ _ <- runPlotM Nothing (defaultTestConfig { captionFormat = fmt+ , defaultDirectory = tempDir+ }) $ make cb+ let (expectedId, _, expectedKeyVals) = expectedAttrs+ assertEqual "identifier" expectedId id'+ assertEqual "key-value pairs" expectedKeyVals keyvals+ where+ extractCaption (B.Figure _ (Caption _ caption) _) = caption + codeBlock :: Toolkit -> Script -> Block codeBlock tk script = CodeBlock (mempty, [cls tk], mempty) script @@ -387,6 +413,9 @@ addWithSource :: Bool -> Block -> Block addWithSource yn (CodeBlock (id', cls, attrs) script) = CodeBlock (id', cls, attrs ++ [(tshow WithSourceK, pack . show $ yn)]) script++setAttrs :: Attr -> Block -> Block+setAttrs attrs (CodeBlock _ script) = CodeBlock attrs script -- | Assert that a file exists assertFileExists :: HasCallStack => FilePath -> Assertion
tests/Main.hs view
@@ -58,6 +58,7 @@ testOverrideConfiguration, testMarkdownFormattingCaption1, testMarkdownFormattingCaption2,+ testAttributesPreservedOnFigure, testCleanOutputDirs, testChecksFail ]