pandoc-plot 0.7.1.0 → 0.7.2.0
raw patch · 9 files changed
+97/−19 lines, 9 filesdep −open-browserdep ~pandocdep ~pandoc-typesdep ~typed-processPVP ok
version bump matches the API change (PVP)
Dependencies removed: open-browser
Dependency ranges changed: pandoc, pandoc-types, typed-process
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- README.md +12/−1
- executable/Main.hs +5/−6
- executable/OpenFile.hs +43/−0
- pandoc-plot.cabal +11/−8
- src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs +1/−1
- src/Text/Pandoc/Filter/Plot/Renderers/Octave.hs +1/−1
- src/Text/Pandoc/Filter/Plot/Renderers/PlotlyR.hs +1/−1
- stack.yaml +16/−1
CHANGELOG.md view
@@ -2,6 +2,13 @@ pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +Release 0.7.2.0 +--------------- + +* Removed dependency on `open-browser` package. +* Starting with this version, `pandoc` 2.8 and 2.9 are **no longer supported** due to a breaking API change in `pandoc` 2.10. +* Executables are now built with GHC 8.10.1. + Release 0.7.1.0 ---------------
README.md view
@@ -29,6 +29,7 @@ - [Installation](#installation) - [Binaries and Installers](#binaries-and-installers) - [conda](#conda) + - [winget](#winget) - [From Hackage/Stackage](#from-hackagestackage) - [From source](#from-source) - [Warning](#warning) @@ -63,7 +64,7 @@ pandoc --filter pandoc-plot input.md --output output.html ``` -*Note that pandoc-plot only works with pandoc \>= 2.8 because of some +*Note that pandoc-plot only works with pandoc \>= 2.10 because of some breaking changes in pandoc’s API.* ## Supported toolkits @@ -699,6 +700,16 @@ ``` sh conda install -c conda-forge pandoc-plot +``` + +### winget + +You can install `pandoc-plot` from the [Windows Package +Manager](https://github.com/microsoft/winget-cli) `winget` (just like +`pandoc`). To install: + +``` sh +winget install pandoc-plot ``` ### From Hackage/Stackage
executable/Main.hs view
@@ -39,7 +39,7 @@ import Text.ParserCombinators.ReadP (readP_to_S) -import Web.Browser (openBrowser) +import OpenFile (openFile) import qualified Data.Version as V import Paths_pandoc_plot (version) @@ -159,10 +159,10 @@ -- indicates whether the Pandoc version is new enough or not. checkRuntimePandocVersion :: IO Bool checkRuntimePandocVersion = do - let minimumPandocVersion = V.Version [2,8,0,0] [] + let minimumPandocVersion = V.Version [2,10,0,0] [] -- Pandoc runs filters in an environment with two variables: -- PANDOV_VERSION and PANDOC_READER_OPTS - -- We can use the former to ensure that people are not using pandoc < 2.8 + -- We can use the former to ensure that people are not using pandoc < 2.10 pandocV <- lookupEnv "PANDOC_VERSION" case pandocV >>= readVersion of Nothing -> return True @@ -170,7 +170,7 @@ then do hPutStrLn stderr $ mconcat [ "ERROR (pandoc-plot) The pandoc-plot filter only " - , "supports Pandoc 2.8 and newer. " + , "supports Pandoc 2.10 and newer. " , "but you are using Pandoc " , showVersion v ] @@ -256,8 +256,7 @@ setLocaleEncoding utf8 -- This is required to write the manual file, for some reason. manualPath <- (</> "pandoc-plot-manual.html") <$> getTemporaryDirectory TIO.writeFile manualPath $(embedManualHtml) - openBrowser ("file:///" <> manualPath) - return () + openFile ("file:///" <> manualPath) -- | Use Doc type directly because of newline formatting footer' :: P.Doc
+ executable/OpenFile.hs view
@@ -0,0 +1,43 @@+{-| +Module : $header$ +Copyright : (c) Laurent P René de Cotret, 2020 +License : GNU GPL, version 2 or above +Maintainer : laurent.decotret@outlook.com +Stability : internal +Portability : portable + +Open a file in its default program. +-} + +module OpenFile (openFile) where + +import Data.List (isInfixOf) +import System.Info (os) +import System.Process.Typed (runProcess_, shell, proc) + + +openFile :: FilePath -> IO () +openFile + -- Aliases taken from cabal's Distribution.System module + | os `elem` ["mingw32", "win32", "cygwin32"] = openFileWindows + | any (`isInfixOf` os) ["linux", "bsd"] = openFileLinux + | os `elem` ["darwin"] = openFileMacOS + | otherwise = error $ "Unsupported OS: " <> os + + +openFileWindows :: FilePath -> IO () +openFileWindows fp = + -- Call looks like: cmd /c 'start "" "my_filepath.html"' + runProcess_ $ shell $ mconcat ["cmd /c start ", quoted mempty, " ", quoted fp] + where + quoted f = mconcat ["\"", f, "\""] + + +openFileLinux :: FilePath -> IO () +openFileLinux fp = + runProcess_ (proc "sh" ["-c", "xdg-open \"$0\" 2>&1 > /dev/null", fp]) + + +openFileMacOS :: FilePath -> IO () +openFileMacOS fp = + runProcess_ (proc "open" [fp])
pandoc-plot.cabal view
@@ -1,6 +1,6 @@+cabal-version: 2.2 name: pandoc-plot -version: 0.7.1.0 -cabal-version: >= 1.12 +version: 0.7.2.0 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 captured and included as a figure. category: Text @@ -9,7 +9,7 @@ bug-reports: https://github.com/LaurentRDC/pandoc-plot/issues author: Laurent P. René de Cotret maintainer: Laurent P. René de Cotret -license: GPL-2 +license: GPL-2.0-or-later license-file: LICENSE build-type: Simple tested-with: GHC == 8.6.5, GHC == 8.8.3 @@ -48,6 +48,8 @@ Text.Pandoc.Filter.Plot.Monad Text.Pandoc.Filter.Plot.Monad.Logging Text.Pandoc.Filter.Plot.Monad.Types + autogen-modules: + Paths_pandoc_plot hs-source-dirs: src ghc-options: @@ -60,8 +62,8 @@ , directory >= 1.2.7 && < 2 , filepath >= 1.4 && < 2 , hashable >= 1 && < 2 - , pandoc >= 2.8 && < 3 - , pandoc-types >= 1.20 && < 2 + , pandoc >= 2.10 && < 3 + , pandoc-types >= 1.21 && < 2 , lifted-async >= 0.10 && < 1 , shakespeare >= 2.0 && < 3 , text >= 1 && < 2 @@ -75,6 +77,7 @@ other-modules: ManPage ExampleConfig + OpenFile Paths_pandoc_plot hs-source-dirs: executable @@ -84,12 +87,12 @@ , directory , filepath , githash >= 0.1.3.0 && < 1 - , open-browser >= 0.2.1.0 , optparse-applicative >= 0.14 && < 1 , pandoc , pandoc-plot - , pandoc-types > 1.12 && <2 - , template-haskell > 2.7 && < 3 + , pandoc-types >= 1.21 && <2 + , template-haskell > 2.7 && < 3 + , typed-process , text default-language: Haskell2010
src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs view
@@ -44,6 +44,6 @@ matlabCapture :: FigureSpec -> FilePath -> Script -matlabCapture FigureSpec{..} fname = [st| +matlabCapture _ fname = [st| saveas(gcf, '#{fname}') |]
src/Text/Pandoc/Filter/Plot/Renderers/Octave.hs view
@@ -40,6 +40,6 @@ octaveCapture :: FigureSpec -> FilePath -> Script -octaveCapture FigureSpec{..} fname = [st| +octaveCapture _ fname = [st| saveas(gcf, '#{fname}') |]
src/Text/Pandoc/Filter/Plot/Renderers/PlotlyR.hs view
@@ -42,7 +42,7 @@ -- Based on the following documentation: -- https://plotly.com/r/static-image-export/ plotlyRCapture :: FigureSpec -> FilePath -> Script -plotlyRCapture FigureSpec{..} fname = [st| +plotlyRCapture _ fname = [st| library(plotly) # just in case if (!require("processx")) install.packages("processx") orca(last_plot(), file = "#{fname}")
stack.yaml view
@@ -1,4 +1,19 @@-resolver: lts-16.0 # GHC 8.8.3 +resolver: nightly-2020-06-29 # GHC 8.10.1 packages: - . + +extra-deps: +- pandoc-2.10 +- hslua-1.1.2@sha256:6c231b2af447430d1ed04f065d40bb6882ece93cc7f32f4051dc99deb69beeae,9694 +- jira-wiki-markup-1.3.2@sha256:b5f0901208a0ee07aff60f5356aeb851b7aa7950c75a18a15fd34247a35886d8,3819 + +# Faster compilation. +# See here: +# https://downloads.haskell.org/ghc/latest/docs/html/users_guide/flags.html#miscellaneous-compiler-options +# and here: +# https://ghc.gitlab.haskell.org/ghc/doc/users_guide/runtime_control.html +# ghc-options: +# pandoc: -j "+RTS -A64m -RTS" +# pandoc-citeproc: -j "+RTS -A64m -RTS" +# $targets: -j "+RTS -A64m -RTS"