diff options
| author | John MacFarlane <[email protected]> | 2022-09-22 09:47:07 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-22 09:47:07 -0700 |
| commit | bd1d923b86edba6e090ba14b1cd17e1e32c727f2 (patch) | |
| tree | d9aa17acc41811a9664815766c72e0f5bf7d239b /pandoc-cli | |
| parent | b38292c2346ebea690eada91a5ac1e0addaa3c0b (diff) | |
Split pandoc-server, pandoc-cli into separate packages. (#8309)
This also removes the unnecessary Setup.hs from pandoc.
Cabal does not need this with build-type 'simple'.
Diffstat (limited to 'pandoc-cli')
| l--------- | pandoc-cli/COPYING.md | 1 | ||||
| -rw-r--r-- | pandoc-cli/README.md | 12 | ||||
| -rw-r--r-- | pandoc-cli/pandoc-cli.cabal | 62 | ||||
| -rw-r--r-- | pandoc-cli/src/pandoc.hs | 33 |
4 files changed, 108 insertions, 0 deletions
diff --git a/pandoc-cli/COPYING.md b/pandoc-cli/COPYING.md new file mode 120000 index 000000000..0c9476f2b --- /dev/null +++ b/pandoc-cli/COPYING.md @@ -0,0 +1 @@ +../COPYING.md
\ No newline at end of file diff --git a/pandoc-cli/README.md b/pandoc-cli/README.md new file mode 100644 index 000000000..9589fce45 --- /dev/null +++ b/pandoc-cli/README.md @@ -0,0 +1,12 @@ +# pandoc-cli + +This package provides the command-line document-conversion program `pandoc`. +There is not much to this package; all of the work is done by +the libraries `pandoc` and `pandoc-server`. + +## License + +© 2006-2022 John MacFarlane ([email protected]). Released under the +[GPL](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html "GNU General Public License"), +version 2 or greater. This software carries no warranty of any kind. +(See COPYRIGHT for full copyright and warranty notices.) diff --git a/pandoc-cli/pandoc-cli.cabal b/pandoc-cli/pandoc-cli.cabal new file mode 100644 index 000000000..e89d05c78 --- /dev/null +++ b/pandoc-cli/pandoc-cli.cabal @@ -0,0 +1,62 @@ +cabal-version: 2.4 +name: pandoc-cli +version: 0.1 +build-type: Simple +license: GPL-2.0-or-later +license-file: COPYING.md +copyright: (c) 2006-2022 John MacFarlane +author: John MacFarlane <[email protected]> +maintainer: John MacFarlane <[email protected]> +bug-reports: https://github.com/jgm/pandoc/issues +stability: alpha +homepage: https://pandoc.org +category: Text +tested-with: GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, + GHC == 9.2.3 +synopsis: Conversion between documentation formats +description: Pandoc-cli provides a command-line executable that uses the pandoc library to convert between markup formats. +-- data-files: +-- extra-source-files: +source-repository head + type: git + location: git://github.com/jgm/pandoc.git + +common common-options + default-language: Haskell2010 + build-depends: base >= 4.12 && < 5 + ghc-options: -Wall -fno-warn-unused-do-bind + -Wincomplete-record-updates + -Wnoncanonical-monad-instances + -Wcpp-undef + -Wincomplete-uni-patterns + -Widentities + -Wpartial-fields + -Wmissing-signatures + -fhide-source-paths + -- -Wmissing-export-lists + + if impl(ghc >= 8.10) + ghc-options: -Wunused-packages + + if impl(ghc >= 9.0) + ghc-options: -Winvalid-haddock + + if os(windows) + cpp-options: -D_WINDOWS + +common common-executable + import: common-options + build-depends: pandoc + ghc-options: -rtsopts -with-rtsopts=-A8m -threaded + +executable pandoc + import: common-executable + hs-source-dirs: src + main-is: pandoc.hs + buildable: True + build-depends: pandoc == 2.19.2, + pandoc-server >= 0.1 && < 0.2, + wai-extra >= 3.0.24, + warp, + safe + diff --git a/pandoc-cli/src/pandoc.hs b/pandoc-cli/src/pandoc.hs new file mode 100644 index 000000000..305fc405e --- /dev/null +++ b/pandoc-cli/src/pandoc.hs @@ -0,0 +1,33 @@ +{- | + Module : Main + Copyright : Copyright (C) 2006-2022 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane <jgm@berkeley@edu> + Stability : alpha + Portability : portable + +Parses command-line options and calls the appropriate readers and +writers. +-} +module Main where +import qualified Control.Exception as E +import Text.Pandoc.App (convertWithOpts, defaultOpts, options, parseOptions) +import Text.Pandoc.Error (handleError) +import Text.Pandoc.Server (ServerOpts(..), parseServerOpts, app) +import Safe (readDef) +import System.Environment (getProgName, lookupEnv) +import qualified Network.Wai.Handler.CGI as CGI +import qualified Network.Wai.Handler.Warp as Warp +import Network.Wai.Middleware.Timeout (timeout) + +main :: IO () +main = E.handle (handleError . Left) $ do + prg <- getProgName + cgiTimeout <- maybe 2 (readDef 2) <$> lookupEnv "PANDOC_SERVER_TIMEOUT" + case prg of + "pandoc-server.cgi" -> CGI.run (timeout cgiTimeout app) + "pandoc-server" -> do + sopts <- parseServerOpts + Warp.run (serverPort sopts) (timeout (serverTimeout sopts) app) + _ -> parseOptions options defaultOpts >>= convertWithOpts |
