diff options
| author | John MacFarlane <[email protected]> | 2022-10-19 09:11:34 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-10-19 09:16:13 -0700 |
| commit | fde8635a181a6ed0cec2a1756fc3e35fee39d29d (patch) | |
| tree | 46180c54701e1267afd69ad61d5f1ee36741c2a0 /src | |
| parent | 4bf685e7ebc5255ab985b9886c88915c0feb8b61 (diff) | |
Split Text.Pandoc.Version from Text.Pandoc.Shared.
This new module exports `pandocVersion` and `pandocVersionText`,
which are no longer exported from Text.Pandoc.Shared. [API change]
Also, we now set the `pandoc-version` variable centrally rather
than in the writers. One effect is the man writer now emits
a comment with the pandoc version (this was intended before,
judging from the template, but it didn't happen because the
vairable wasn't set).
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Filter/JSON.hs | 3 | ||||
| -rw-r--r-- | src/Text/Pandoc/Shared.hs | 13 | ||||
| -rw-r--r-- | src/Text/Pandoc/Version.hs | 28 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Man.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Ms.hs | 1 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/ODT.hs | 3 |
8 files changed, 36 insertions, 18 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 2f2b396af..fb8a49334 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -73,7 +73,7 @@ import Text.Pandoc.Generic import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Readers -import Text.Pandoc.Shared (pandocVersion, pandocVersionText) +import Text.Pandoc.Version (pandocVersion, pandocVersionText) import Text.Pandoc.Templates import Text.Pandoc.Translations (setTranslations, translateTerm) import Text.Pandoc.Writers diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index d38618198..56020cd1f 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -181,6 +181,8 @@ optToOutputSettings scriptingEngine opts = do >>= setVariableM "outputfile" (T.pack outputFile) >>= + setVariableM "pandoc-version" pandocVersionText + >>= setFilesVariableM "include-before" (optIncludeBeforeBody opts) >>= setFilesVariableM "include-after" (optIncludeAfterBody opts) diff --git a/src/Text/Pandoc/Filter/JSON.hs b/src/Text/Pandoc/Filter/JSON.hs index c3019c679..883e3c7c4 100644 --- a/src/Text/Pandoc/Filter/JSON.hs +++ b/src/Text/Pandoc/Filter/JSON.hs @@ -27,7 +27,8 @@ 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 (pandocVersionText, tshow) +import Text.Pandoc.Version (pandocVersionText) +import Text.Pandoc.Shared (tshow) import qualified Control.Exception as E import qualified Text.Pandoc.UTF8 as UTF8 diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 0a836847b..b2d14c52a 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -88,9 +88,6 @@ module Text.Pandoc.Shared ( safeStrRead, -- * User data directory defaultUserDataDir, - -- * Version - pandocVersion, - pandocVersionText ) where import Codec.Archive.Zip @@ -110,8 +107,6 @@ 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 (Version, showVersion) -import Paths_pandoc (version) import System.Directory import System.FilePath (isPathSeparator, splitDirectories) import qualified System.FilePath.Posix as Posix @@ -127,14 +122,6 @@ import Text.Pandoc.Generic (bottomUp) import Text.DocLayout (charWidth) import Text.Pandoc.Walk --- | Version number of pandoc library. -pandocVersion :: Version -pandocVersion = version - --- | Text representation of the library's version number. -pandocVersionText :: T.Text -pandocVersionText = T.pack $ showVersion version - -- -- List processing -- diff --git a/src/Text/Pandoc/Version.hs b/src/Text/Pandoc/Version.hs new file mode 100644 index 000000000..e5d1c2a74 --- /dev/null +++ b/src/Text/Pandoc/Version.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE CPP #-} +{- | + Module : Text.Pandoc.Version + Copyright : Copyright (C) 2022 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane <[email protected]> + Stability : alpha + Portability : portable + +Version information. +-} +module Text.Pandoc.Version ( + pandocVersion, + pandocVersionText + ) where + +import Data.Version (Version, showVersion) +import Paths_pandoc (version) +import qualified Data.Text as T + +-- | Version number of pandoc library. +pandocVersion :: Version +pandocVersion = version + +-- | Text representation of the library's version number. +pandocVersionText :: T.Text +pandocVersionText = T.pack $ showVersion version diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index fd4d52d3c..f4d829059 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -74,7 +74,7 @@ pandocToMan opts (Pandoc meta blocks) = do $ setFieldsFromTitle $ defField "has-tables" hasTables $ defField "hyphenate" True - $ defField "pandoc-version" pandocVersionText metadata + $ metadata return $ render colwidth $ case writerTemplate opts of Nothing -> main diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs index 5592b3d86..ceff1697f 100644 --- a/src/Text/Pandoc/Writers/Ms.hs +++ b/src/Text/Pandoc/Writers/Ms.hs @@ -76,7 +76,6 @@ pandocToMs opts (Pandoc meta blocks) = do let context = defField "body" main $ defField "has-inline-math" hasInlineMath $ defField "hyphenate" True - $ defField "pandoc-version" pandocVersionText $ defField "toc" (writerTableOfContents opts) $ defField "title-meta" titleMeta $ defField "author-meta" (T.intercalate "; " authorsMeta) diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 77289faea..302debe7f 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -35,7 +35,8 @@ import Text.Pandoc.Logging import Text.Pandoc.MIME (extensionFromMimeType, getMimeType) import Text.Pandoc.Options (WrapOption (..), WriterOptions (..)) import Text.DocLayout -import Text.Pandoc.Shared (stringify, pandocVersionText, tshow) +import Text.Pandoc.Shared (stringify, tshow) +import Text.Pandoc.Version (pandocVersionText) import Text.Pandoc.Writers.Shared (lookupMetaString, lookupMetaBlocks, fixDisplayMath, getLang, ensureValidXmlIdentifiers) |
