Blame INSTALL.md

Packit dda32d
# Installing pandoc
Packit dda32d
Packit dda32d
## Windows
Packit dda32d
Packit dda32d
  - There is a package installer at pandoc's [download page].
Packit dda32d
    This will install pandoc, replacing older versions, and
Packit dda32d
    update your path to include the directory where pandoc's
Packit dda32d
    binaries are installed.
Packit dda32d
Packit dda32d
  - If you prefer not to use the msi installer, we also provide
Packit dda32d
    a zip file that contains pandoc's binaries and
Packit dda32d
    documentation.  Simply unzip this file and move the binaries
Packit dda32d
    to a directory of your choice.
Packit dda32d
Packit dda32d
  - For PDF output, you'll also need to install LaTeX.
Packit dda32d
    We recommend [MiKTeX](http://miktex.org/).
Packit dda32d
Packit dda32d
## macOS
Packit dda32d
Packit dda32d
  - You can install pandoc using
Packit dda32d
    [homebrew](http://brew.sh): `brew install pandoc`.
Packit dda32d
Packit dda32d
  - There is a package installer at pandoc's [download page].
Packit dda32d
    If you later want to uninstall the package, you can do so
Packit dda32d
    by downloading [this script][uninstaller]
Packit dda32d
    and running it with `perl uninstall-pandoc.pl`.
Packit dda32d
Packit dda32d
  - We also provide a zip file containing the binaries and man
Packit dda32d
    pages, for those who prefer not to use the installer.  Simply
Packit dda32d
    unzip the file and move the binaries and man pages to
Packit dda32d
    whatever directory you like.
Packit dda32d
Packit dda32d
  - For PDF output, you'll also need LaTeX.  Because a full [MacTeX]
Packit dda32d
    installation takes more than a gigabyte of disk space, we recommend
Packit dda32d
    installing [BasicTeX](http://www.tug.org/mactex/morepackages.html)
Packit dda32d
    (64M) and using the `tlmgr` tool to install additional packages
Packit dda32d
    as needed.  If you get errors warning of fonts not found, try
Packit dda32d
Packit dda32d
        tlmgr install collection-fontsrecommended
Packit dda32d
Packit dda32d
## Linux
Packit dda32d
Packit dda32d
  - First, try your package manager.
Packit dda32d
    Pandoc is in the [Debian], [Ubuntu], [Slackware],
Packit dda32d
    [Arch], [Fedora], [NiXOS], [openSUSE], and [gentoo] repositories.
Packit dda32d
    Note, however, that versions in the repositories are often
Packit dda32d
    old.
Packit dda32d
Packit dda32d
  - We provide a binary package for amd64 architecture on
Packit dda32d
    the [download page].  This provides both `pandoc` and
Packit dda32d
    `pandoc-citeproc`. The executables are statically linked and
Packit dda32d
    have no dynamic dependencies or dependencies on external
Packit dda32d
    data files.  Note:  because of the static
Packit dda32d
    linking, the pandoc binary from this package cannot use lua
Packit dda32d
    filters that require external lua modules written in C.
Packit dda32d
Packit dda32d
    Both a tarball and a deb installer are provided.  To install the deb:
Packit dda32d
Packit dda32d
        sudo dpkg -i $DEB
Packit dda32d
Packit dda32d
    where `$DEB` is the path to the downloaded deb.  This will
Packit dda32d
    install the `pandoc` and `pandoc-citeproc` executables and
Packit dda32d
    man pages.
Packit dda32d
Packit dda32d
    If you use an RPM-based distro, you may be able to install
Packit dda32d
    the deb from our download page using `alien`.
Packit dda32d
Packit dda32d
    On any distro, you may install from the tarball into `$DEST`
Packit dda32d
    (say, `/usr/local/` or `$HOME/.local`) by doing
Packit dda32d
Packit dda32d
        tar xvzf $TGZ --strip-components 1 -C $DEST
Packit dda32d
Packit dda32d
    where `$TGZ` is the path to the downloaded zipped tarball.
Packit dda32d
    For Pandoc versions before 2.0, which don't provide
Packit dda32d
    a tarball, try instead
Packit dda32d
Packit dda32d
        ar p $DEB data.tar.gz | tar xvz --strip-components 2 -C $DEST
Packit dda32d
Packit dda32d
  - You can also install from source, using the
Packit dda32d
    instructions below under [Compiling from source].
Packit dda32d
    Note that most distros have the Haskell platform in their
Packit dda32d
    package repositories.  For example, on Debian/Ubuntu,
Packit dda32d
    you can install it with `apt-get install haskell-platform`.
Packit dda32d
Packit dda32d
  - For PDF output, you'll need LaTeX.  We recommend installing
Packit dda32d
    [TeX Live](http://www.tug.org/texlive/) via your package
Packit dda32d
    manager.  (On Debian/Ubuntu, `apt-get install texlive`.)
Packit dda32d
Packit dda32d
## BSD
Packit dda32d
Packit dda32d
  - Pandoc is in the [NetBSD] and [FreeBSD ports] repositories.
Packit dda32d
Packit dda32d
## Compiling from source
Packit dda32d
Packit dda32d
If for some reason a binary package is not available for your
Packit dda32d
platform, or if you want to hack on pandoc or use a non-released
Packit dda32d
version, you can install from source.
Packit dda32d
Packit dda32d
### Getting the pandoc source code
Packit dda32d
Packit dda32d
Source tarballs can be found at
Packit dda32d
<https://hackage.haskell.org/package/pandoc>.  For example, to
Packit dda32d
fetch the source for version 1.17.0.3:
Packit dda32d
Packit dda32d
    wget https://hackage.haskell.org/package/pandoc-1.17.0.3/pandoc-1.17.0.3.tar.gz
Packit dda32d
    tar xvzf pandoc-1.17.0.3.tar.gz
Packit dda32d
    cd pandoc-1.17.0.3
Packit dda32d
Packit dda32d
Or you can fetch the development code by cloning the repository:
Packit dda32d
Packit dda32d
    git clone https://github.com/jgm/pandoc
Packit dda32d
    cd pandoc
Packit dda32d
Packit dda32d
Note:  there may be times when the development code is broken
Packit dda32d
or depends on other libraries which must be installed
Packit dda32d
separately.  Unless you really know what you're doing, install
Packit dda32d
the last released version.
Packit dda32d
Packit dda32d
### Quick stack method
Packit dda32d
Packit dda32d
The easiest way to build pandoc from source is to use [stack]:
Packit dda32d
Packit dda32d
1.  Install [stack].
Packit dda32d
Packit dda32d
2.  Change to the pandoc source directory and issue the following commands:
Packit dda32d
Packit dda32d
        stack setup
Packit dda32d
        stack install --test
Packit dda32d
Packit dda32d
    `stack setup` will automatically download the ghc compiler
Packit dda32d
    if you don't have it.  `stack install` will install the
Packit dda32d
    `pandoc` executable into `~/.local/bin`, which you should
Packit dda32d
    add to your `PATH`.  This process will take a while, and
Packit dda32d
    will consume a considerable amount of disk space.
Packit dda32d
Packit dda32d
### Quick cabal method
Packit dda32d
Packit dda32d
1.  Install the [Haskell platform].  This will give you [GHC] and
Packit dda32d
    the [cabal-install] build tool.  Note that pandoc requires
Packit dda32d
    GHC >= 7.8.
Packit dda32d
Packit dda32d
2.  Update your package database:
Packit dda32d
Packit dda32d
        cabal update
Packit dda32d
Packit dda32d
3.  Use `cabal` to install pandoc and its dependencies:
Packit dda32d
Packit dda32d
        cabal install pandoc --enable-tests
Packit dda32d
Packit dda32d
    This procedure will install the released version of pandoc,
Packit dda32d
    which will be downloaded automatically from HackageDB.
Packit dda32d
Packit dda32d
    If you want to install a modified or development version
Packit dda32d
    of pandoc instead, switch to the source directory and do
Packit dda32d
    as above, but without the 'pandoc':
Packit dda32d
Packit dda32d
        cabal install
Packit dda32d
Packit dda32d
4.  Make sure the `$CABALDIR/bin` directory is in your path.  You should
Packit dda32d
    now be able to run `pandoc`:
Packit dda32d
Packit dda32d
        pandoc --help
Packit dda32d
Packit dda32d
    [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)
Packit dda32d
Packit dda32d
5.  If you want to process citations with pandoc, you will also need to
Packit dda32d
    install a separate package, `pandoc-citeproc`.  This can be installed
Packit dda32d
    using cabal:
Packit dda32d
Packit dda32d
        cabal install pandoc-citeproc
Packit dda32d
Packit dda32d
    By default `pandoc-citeproc` uses the "i;unicode-casemap" method
Packit dda32d
    to sort bibliography entries (RFC 5051).  If you would like to
Packit dda32d
    use the locale-sensitive unicode collation algorithm instead,
Packit dda32d
    specify the `unicode_collation` flag:
Packit dda32d
Packit dda32d
        cabal install pandoc-citeproc -funicode_collation
Packit dda32d
Packit dda32d
    Note that this requires the `text-icu` library, which in turn
Packit dda32d
    depends on the C library `icu4c`.  Installation directions
Packit dda32d
    vary by platform.  Here is how it might work on macOS with homebrew:
Packit dda32d
Packit dda32d
        brew install icu4c
Packit dda32d
        cabal install --extra-lib-dirs=/usr/local/Cellar/icu4c/51.1/lib \
Packit dda32d
          --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \
Packit dda32d
          -funicode_collation text-icu pandoc-citeproc
Packit dda32d
Packit dda32d
6.  The `pandoc.1` man page will be installed automatically.  cabal shows
Packit dda32d
    you where it is installed: you may need to set your `MANPATH`
Packit dda32d
    accordingly. If `MANUAL.txt` has been modified, the man page can be
Packit dda32d
    rebuilt: `make man/pandoc.1`.
Packit dda32d
Packit dda32d
    The `pandoc-citeproc.1` man page will also be installed automatically.
Packit dda32d
Packit dda32d
Packit dda32d
### Custom cabal method
Packit dda32d
Packit dda32d
This is a step-by-step procedure that offers maximal control
Packit dda32d
over the build and installation.  Most users should use the
Packit dda32d
quick install, but this information may be of use to packagers.
Packit dda32d
For more details, see the [Cabal User's Guide].  These instructions
Packit dda32d
assume that the pandoc source directory is your working directory.
Packit dda32d
Packit dda32d
1.  Install dependencies:  in addition to the [Haskell platform],
Packit dda32d
    you will need a number of additional libraries.  You can install
Packit dda32d
    them all with
Packit dda32d
Packit dda32d
        cabal update
Packit dda32d
        cabal install --only-dependencies
Packit dda32d
Packit dda32d
2.  Configure:
Packit dda32d
Packit dda32d
        cabal configure --prefix=DIR --bindir=DIR --libdir=DIR \
Packit dda32d
          --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \
Packit dda32d
          --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \
Packit dda32d
          --mandir=DIR --flags=FLAGSPEC --enable-tests
Packit dda32d
Packit dda32d
    All of the options have sensible defaults that can be overridden
Packit dda32d
    as needed.
Packit dda32d
Packit dda32d
    `FLAGSPEC` is a list of Cabal configuration flags, optionally
Packit dda32d
    preceded by a `-` (to force the flag to `false`), and separated
Packit dda32d
    by spaces.  Pandoc's flags include:
Packit dda32d
Packit dda32d
    - `embed_data_files`: embed all data files into the binary (default no).
Packit dda32d
      This is helpful if you want to create a relocatable binary.
Packit dda32d
Packit dda32d
    - `https`:  enable support for downloading resources over https
Packit dda32d
      (using the `http-client` and `http-client-tls` libraries).
Packit dda32d
Packit dda32d
3.  Build:
Packit dda32d
Packit dda32d
        cabal build
Packit dda32d
        cabal test
Packit dda32d
Packit dda32d
4.  Build API documentation:
Packit dda32d
Packit dda32d
        cabal haddock --html-location=URL --hyperlink-source
Packit dda32d
Packit dda32d
5.  Copy the files:
Packit dda32d
Packit dda32d
        cabal copy --destdir=PATH
Packit dda32d
Packit dda32d
    The default destdir is `/`.
Packit dda32d
Packit dda32d
6.  Register pandoc as a GHC package:
Packit dda32d
Packit dda32d
        cabal register
Packit dda32d
Packit dda32d
    Package managers may want to use the `--gen-script` option to
Packit dda32d
    generate a script that can be run to register the package at
Packit dda32d
    install time.
Packit dda32d
Packit dda32d
### Creating a relocatable binary
Packit dda32d
Packit dda32d
It is possible to compile pandoc such that the data files
Packit dda32d
pandoc uses are embedded in the binary.  The resulting binary
Packit dda32d
can be run from any directory and is completely self-contained.
Packit dda32d
With cabal, add `-fembed_data_files` to the `cabal configure`
Packit dda32d
or `cabal install` commands.
Packit dda32d
Packit dda32d
With stack, use `--flag pandoc:embed_data_files`.
Packit dda32d
Packit dda32d
Packit dda32d
Packit dda32d
### Running tests
Packit dda32d
Packit dda32d
Pandoc comes with an automated test suite.
Packit dda32d
To run with cabal, `cabal test`; to run with stack, `stack
Packit dda32d
test`.
Packit dda32d
Packit dda32d
To run particular tests (pattern-matching on their names), use
Packit dda32d
the `-p` option:
Packit dda32d
Packit dda32d
    cabal test --test-options='-p markdown'
Packit dda32d
Packit dda32d
Or with stack:
Packit dda32d
Packit dda32d
    stack test --test-arguments='-p markdown'
Packit dda32d
Packit dda32d
It is often helpful to add `-j4` (run tests in parallel)
Packit dda32d
and `--hide-successes` (don't clutter output with successes)
Packit dda32d
to the test arguments as well.
Packit dda32d
Packit dda32d
If you add a new feature to pandoc, please add tests as well, following
Packit dda32d
the pattern of the existing tests. The test suite code is in
Packit dda32d
`test/test-pandoc.hs`. If you are adding a new reader or writer, it is
Packit dda32d
probably easiest to add some data files to the `test` directory, and
Packit dda32d
modify `test/Tests/Old.hs`. Otherwise, it is better to modify the module
Packit dda32d
under the `test/Tests` hierarchy corresponding to the pandoc module you
Packit dda32d
are changing.
Packit dda32d
Packit dda32d
### Running benchmarks
Packit dda32d
Packit dda32d
To build and run the benchmarks:
Packit dda32d
Packit dda32d
    cabal configure --enable-benchmarks && cabal build
Packit dda32d
    cabal bench
Packit dda32d
Packit dda32d
or with stack:
Packit dda32d
Packit dda32d
    stack bench
Packit dda32d
Packit dda32d
To use a smaller sample size so the benchmarks run faster:
Packit dda32d
Packit dda32d
    cabal bench --benchmark-options='-s 20'
Packit dda32d
Packit dda32d
To run just the markdown benchmarks:
Packit dda32d
Packit dda32d
    cabal bench --benchmark-options='markdown'
Packit dda32d
Packit dda32d
Packit dda32d
[Arch]: https://www.archlinux.org/packages/community/x86_64/pandoc/
Packit dda32d
[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths
Packit dda32d
[Debian]: https://packages.debian.org/pandoc
Packit dda32d
[Fedora]: https://apps.fedoraproject.org/packages/pandoc
Packit dda32d
[FreeBSD ports]: http://www.freshports.org/textproc/pandoc/
Packit dda32d
[GHC]:  http://www.haskell.org/ghc/
Packit dda32d
[GPL]:  http://www.gnu.org/copyleft/gpl.html
Packit dda32d
[Haskell platform]: http://hackage.haskell.org/platform/
Packit dda32d
[MacPorts]: http://trac.macports.org/browser/trunk/dports/textproc/pandoc/Portfile
Packit dda32d
[MacTeX]: https://tug.org/mactex/
Packit dda32d
[NetBSD]: http://pkgsrc.se/wip/pandoc
Packit dda32d
[NixOS]: https://nixos.org/nixos/packages.html
Packit dda32d
[Slackware]: https://www.slackbuilds.org/result/?search=pandoc&sv=
Packit dda32d
[Ubuntu]: https://packages.ubuntu.com/pandoc
Packit dda32d
[download page]: https://github.com/jgm/pandoc/releases/latest
Packit dda32d
[gentoo]: http://packages.gentoo.org/package/app-text/pandoc
Packit dda32d
[haskell repository]: https://wiki.archlinux.org/index.php/Haskell_Package_Guidelines#.5Bhaskell.5D
Packit dda32d
[openSUSE]: https://software.opensuse.org/package/pandoc
Packit dda32d
[source tarball]: http://hackage.haskell.org/package/pandoc
Packit dda32d
[stack]: http://docs.haskellstack.org/en/stable/install_and_upgrade.html
Packit dda32d
[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
Packit dda32d
[uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/macos/uninstall-pandoc.pl