[API Change] Rename pandocVersion to pandocVersionText...

and add a new `pandocVersion` value with type `Version`. This is
consistent with the type used for `pandocTypesVersion` and allows to use
the value where a Version type is required.
This commit is contained in:
Albert Krewinkel
2022-09-29 09:45:14 +02:00
committed by John MacFarlane
parent e099de1d4d
commit ddaadc88bc
11 changed files with 26 additions and 20 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ import Text.Pandoc.App ( convertWithOpts, defaultOpts, options
import Text.Pandoc.Class (runIOorExplode)
import Text.Pandoc.Error (handleError)
import Text.Pandoc.Lua (runLua, runLuaNoEnv)
import Text.Pandoc.Shared (pandocVersion)
import Text.Pandoc.Shared (pandocVersionText)
import qualified Text.Pandoc.UTF8 as UTF8
import PandocCLI.Server
@@ -45,7 +45,7 @@ main = E.handle (handleError . Left) $ do
runLuaInterpreter :: String -> [String] -> IO ()
runLuaInterpreter progName args = do
let settings = Settings
{ settingsVersionInfo = "\nEmbedded in pandoc " <> pandocVersion
{ settingsVersionInfo = "\nEmbedded in pandoc " <> pandocVersionText
, settingsRunner = runner
}
runStandalone settings progName args
+2 -2
View File
@@ -85,7 +85,7 @@ cliOptions =
, Option ['v'] ["version"]
(NoArg (\_ -> do
prg <- getProgName
putStrLn $ prg <> " " <> T.unpack pandocVersion
putStrLn $ prg <> " " <> T.unpack pandocVersionText
exitWith ExitSuccess))
"version info"
@@ -208,7 +208,7 @@ server = convertBytes
:<|> convertJSON
:<|> mapM convertJSON
:<|> babelmark -- for babelmark which expects {"html": "", "version": ""}
:<|> pure pandocVersion
:<|> pure pandocVersionText
where
babelmark text' from' to' standalone' = do
res <- convertText def{
+2 -1
View File
@@ -57,6 +57,7 @@ module Text.Pandoc
, module Text.Pandoc.Templates
-- * Miscellaneous
, pandocVersion
, pandocVersionText
) where
import Text.Pandoc.Class
@@ -66,6 +67,6 @@ import Text.Pandoc.Generic
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Readers
import Text.Pandoc.Shared (pandocVersion)
import Text.Pandoc.Shared (pandocVersion, pandocVersionText)
import Text.Pandoc.Templates
import Text.Pandoc.Writers
+1 -1
View File
@@ -966,7 +966,7 @@ options =
peek top
UTF8.hPutStrLn stdout
$ T.pack
$ prg ++ " " ++ T.unpack pandocVersion ++ versionSuffix ++
$ prg ++ " " ++ T.unpack pandocVersionText ++ versionSuffix ++
compileInfo ++ "\nScripting engine: " ++ luaVersion ++
"\nUser data directory: " ++ defaultDatadir ++
('\n':copyrightMessage)
+2 -2
View File
@@ -27,7 +27,7 @@ import Text.Pandoc.Definition (Pandoc)
import Text.Pandoc.Error (PandocError (PandocFilterError))
import Text.Pandoc.Filter.Environment (Environment (..))
import Text.Pandoc.Process (pipeProcess)
import Text.Pandoc.Shared (pandocVersion, tshow)
import Text.Pandoc.Shared (pandocVersionText, tshow)
import qualified Control.Exception as E
import qualified Text.Pandoc.UTF8 as UTF8
@@ -65,7 +65,7 @@ externalFilter fenv f args' d = liftIO $ do
let ropts = envReaderOptions fenv
env <- getEnvironment
let env' = Just
( ("PANDOC_VERSION", T.unpack pandocVersion)
( ("PANDOC_VERSION", T.unpack pandocVersionText)
: ("PANDOC_READER_OPTIONS", UTF8.toStringLazy (encode ropts))
: env )
(exitcode, outbs) <- E.handle filterException $
+2 -2
View File
@@ -16,7 +16,6 @@ module Text.Pandoc.Lua.Global
import HsLua as Lua
import HsLua.Module.Version (pushVersion)
import Paths_pandoc (version)
import Text.Pandoc.Class.CommonState (CommonState)
import Text.Pandoc.Definition (Pandoc, pandocTypesVersion)
import Text.Pandoc.Error (PandocError)
@@ -26,6 +25,7 @@ import Text.Pandoc.Lua.Marshal.ReaderOptions (pushReaderOptionsReadonly)
import Text.Pandoc.Lua.Marshal.WriterOptions (pushWriterOptions)
import Text.Pandoc.Lua.Orphans ()
import Text.Pandoc.Options (ReaderOptions, WriterOptions)
import Text.Pandoc.Shared (pandocVersion)
import qualified Data.Text as Text
@@ -70,5 +70,5 @@ setGlobal global = case global of
pushCommonState commonState
Lua.setglobal "PANDOC_STATE"
PANDOC_VERSION -> do
pushVersion version
pushVersion pandocVersion
Lua.setglobal "PANDOC_VERSION"
+9 -4
View File
@@ -93,7 +93,8 @@ module Text.Pandoc.Shared (
-- * User data directory
defaultUserDataDir,
-- * Version
pandocVersion
pandocVersion,
pandocVersionText
) where
import Codec.Archive.Zip
@@ -113,7 +114,7 @@ import Data.Monoid (Any (..))
import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr)
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Version (showVersion)
import Data.Version (Version, showVersion)
import Network.URI (URI (uriScheme), escapeURIString, parseURI)
import Paths_pandoc (version)
import System.Directory
@@ -132,8 +133,12 @@ import Text.DocLayout (charWidth)
import Text.Pandoc.Walk
-- | Version number of pandoc library.
pandocVersion :: T.Text
pandocVersion = T.pack $ showVersion version
pandocVersion :: Version
pandocVersion = version
-- | Text representation of the library's version number.
pandocVersionText :: T.Text
pandocVersionText = T.pack $ showVersion version
--
-- List processing
+1 -1
View File
@@ -73,7 +73,7 @@ pandocToMan opts (Pandoc meta blocks) = do
$ setFieldsFromTitle
$ defField "has-tables" hasTables
$ defField "hyphenate" True
$ defField "pandoc-version" pandocVersion metadata
$ defField "pandoc-version" pandocVersionText metadata
return $ render colwidth $
case writerTemplate opts of
Nothing -> main
+1 -1
View File
@@ -76,7 +76,7 @@ pandocToMs opts (Pandoc meta blocks) = do
let context = defField "body" main
$ defField "has-inline-math" hasInlineMath
$ defField "hyphenate" True
$ defField "pandoc-version" pandocVersion
$ defField "pandoc-version" pandocVersionText
$ defField "toc" (writerTableOfContents opts)
$ defField "title-meta" titleMeta
$ defField "author-meta" (T.intercalate "; " authorsMeta)
+2 -2
View File
@@ -34,7 +34,7 @@ import Text.Pandoc.Logging
import Text.Pandoc.MIME (extensionFromMimeType, getMimeType)
import Text.Pandoc.Options (WrapOption (..), WriterOptions (..))
import Text.DocLayout
import Text.Pandoc.Shared (stringify, pandocVersion, tshow)
import Text.Pandoc.Shared (stringify, pandocVersionText, tshow)
import Text.Pandoc.Writers.Shared (lookupMetaString, lookupMetaBlocks,
fixDisplayMath, getLang,
ensureValidXmlIdentifiers)
@@ -139,7 +139,7 @@ pandocToODT opts doc@(Pandoc meta _) = do
,("xmlns:ooo","http://openoffice.org/2004/office")
,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")
,("office:version","1.2")] ( inTags True "office:meta" []
( metaTag "meta:generator" ("Pandoc/" <> pandocVersion)
( metaTag "meta:generator" ("Pandoc/" <> pandocVersionText)
$$
metaTag "dc:title" (stringify title)
$$
+2 -2
View File
@@ -31,7 +31,7 @@ import Text.Pandoc.Error (PandocError (PandocLuaError))
import Text.Pandoc.Filter (Filter (LuaFilter), applyFilters)
import Text.Pandoc.Lua (Global (..), runLua, setGlobals)
import Text.Pandoc.Options (def)
import Text.Pandoc.Shared (pandocVersion)
import Text.Pandoc.Shared (pandocVersionText)
import qualified Control.Monad.Catch as Catch
import qualified Data.Text as T
@@ -149,7 +149,7 @@ tests =
, testCase "Pandoc version is set" . runLuaTest $ do
Lua.getglobal "PANDOC_VERSION"
Lua.liftIO .
assertEqual "pandoc version is wrong" (TE.encodeUtf8 pandocVersion)
assertEqual "pandoc version is wrong" (TE.encodeUtf8 pandocVersionText)
=<< Lua.tostring' Lua.top
, testCase "Pandoc types version is set" . runLuaTest $ do