mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-27 09:55:57 +00:00
[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:
committed by
John MacFarlane
parent
e099de1d4d
commit
ddaadc88bc
+2
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 $
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
$$
|
||||
|
||||
Reference in New Issue
Block a user