1# Installing pandoc
2
3The simplest way to get the latest pandoc release is to use the installer.
4
5<a href="https://github.com/jgm/pandoc/releases/latest"
6  class="btn btn-primary" id="downloadInstallerBtn">
7  Download the latest installer
8</a>
9
10For alternative ways to install pandoc, see below
11under the heading for your operating system.
12
13## Windows
14
15There is a package installer at pandoc's [download page].
16This will install pandoc, replacing older versions, and
17update your path to include the directory where pandoc's
18binaries are installed.
19
20If you prefer not to use the msi installer, we also provide
21a zip file that contains pandoc's binaries and
22documentation.  Simply unzip this file and move the binaries
23to a directory of your choice.
24
25Alternatively, you can install pandoc using
26[Chocolatey](https://chocolatey.org):
27
28    choco install pandoc
29
30Chocolatey can also install other software that integrates with Pandoc.
31For example, to install `rsvg-convert` (from [librsvg], covering formats
32without SVG support), [Python] (to use Pandoc filters), and
33[MiKTeX] (to typeset PDFs with [LaTeX]):
34
35    choco install rsvg-convert python miktex
36
37By default, Pandoc creates PDFs using LaTeX.
38We recommend installing it via [MiKTeX].
39
40## macOS
41
42There is a package installer at pandoc's [download page].
43If you later want to uninstall the package, you can do so
44by downloading [this script][uninstaller]
45and running it with `perl uninstall-pandoc.pl`.
46
47Alternatively, you can install pandoc using
48[Homebrew](http://brew.sh):
49
50     brew install pandoc
51
52Homebrew can also install other software that integrates with Pandoc.
53For example, to install [librsvg] (its `rsvg-convert` covers formats
54without SVG support), [Python] (to use Pandoc filters), and
55[BasicTeX] (to typeset PDFs with [LaTeX]):
56
57     brew install librsvg python homebrew/cask/basictex
58
59Note: On unsupported versions of macOS (more than three releases old),
60Homebrew installs from source, which takes additional time and disk space
61for the `ghc` compiler and dependent Haskell libraries.
62
63We also provide a zip file containing the binaries and man
64pages, for those who prefer not to use the installer.  Simply
65unzip the file and move the binaries and man pages to
66whatever directory you like.
67
68By default, Pandoc creates PDFs using LaTeX.  Because a full [MacTeX]
69installation uses four gigabytes of disk space, we recommend
70[BasicTeX] or [TinyTeX](https://yihui.org/tinytex/)
71and using the `tlmgr` tool to install additional packages
72as needed.  If you receive errors warning of fonts not found:
73
74    tlmgr install collection-fontsrecommended
75
76## Linux
77
78Check whether the pandoc version in your package manager is
79not outdated. Pandoc is in the [Debian], [Ubuntu], [Slackware],
80[Arch], [Fedora], [NiXOS], [openSUSE], [gentoo] and [Void] repositories.
81
82To get the latest release, we provide a binary package for amd64
83architecture on the **[download page]**.
84
85The executable is statically linked and
86has no dynamic dependencies or dependencies on external
87data files.  Note:  because of the static
88linking, the pandoc binary from this package cannot use lua
89filters that require external lua modules written in C.
90
91Both a tarball and a deb installer are provided.  To install the deb:
92
93    sudo dpkg -i $DEB
94
95where `$DEB` is the path to the downloaded deb.  This will
96install the `pandoc` executable and man page.
97
98If you use an RPM-based distro, you may be able to install
99the deb from our download page using `alien`.
100
101On any distro, you may install from the tarball into `$DEST`
102(say, `/usr/local/` or `$HOME/.local`) by doing
103
104    tar xvzf $TGZ --strip-components 1 -C $DEST
105
106where `$TGZ` is the path to the downloaded zipped tarball.
107For Pandoc versions before 2.0, which don't provide
108a tarball, try instead
109
110    ar p $DEB data.tar.gz | tar xvz --strip-components 2 -C $DEST
111
112You can also install from source, using the
113instructions below under [Compiling from source].
114Note that most distros have the Haskell platform in their
115package repositories.  For example, on Debian/Ubuntu,
116you can install it with `apt-get install haskell-platform`.
117
118For PDF output, you'll need LaTeX.  We recommend installing
119[TeX Live](http://www.tug.org/texlive/) via your package
120manager.  (On Debian/Ubuntu, `apt-get install texlive`.)
121
122## Chrome OS
123
124On Chrome OS, pandoc can be installed using the
125[chromebrew](https://github.com/skycocker/chromebrew) package manager
126with the command:
127
128```sh
129crew install pandoc
130```
131
132This will automatically build and configure pandoc for the specific
133device you are using.
134
135## BSD
136
137Pandoc is in the [NetBSD] and [FreeBSD ports] repositories.
138
139## Docker
140
141The official Docker images for pandoc can be found at
142<https://github.com/pandoc/dockerfiles> and at
143[dockerhub](https://hub.docker.com/).
144
145The [pandoc/core](https://hub.docker.com/r/pandoc/core)
146image contains `pandoc`.
147
148The [pandoc/latex](https://hub.docker.com/r/pandoc/latex)
149image also contains the minimal LaTeX installation needed
150to produce PDFs using pandoc.
151
152To run pandoc using Docker, converting `README.md` to `README.pdf`:
153
154    docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex README.md -o README.pdf
155
156## GitHub Actions
157
158Pandoc can be run through
159[GitHub Actions](https://github.com/features/actions).  For some
160examples, see <https://github.com/pandoc/pandoc-action-example>.
161
162## Compiling from source
163
164If for some reason a binary package is not available for your
165platform, or if you want to hack on pandoc or use a non-released
166version, you can install from source.
167
168### Getting the pandoc source code
169
170Source tarballs can be found at
171<https://hackage.haskell.org/package/pandoc>.  For example, to
172fetch the source for version 1.17.0.3:
173
174    wget https://hackage.haskell.org/package/pandoc-1.17.0.3/pandoc-1.17.0.3.tar.gz
175    tar xvzf pandoc-1.17.0.3.tar.gz
176    cd pandoc-1.17.0.3
177
178Or you can fetch the development code by cloning the repository:
179
180    git clone https://github.com/jgm/pandoc
181    cd pandoc
182
183Note:  there may be times when the development code is broken
184or depends on other libraries which must be installed
185separately.  Unless you really know what you're doing, install
186the last released version.
187
188### Quick stack method
189
190The easiest way to build pandoc from source is to use [stack][stack]:
191
1921.  Install [stack][stack]. Note that Pandoc requires stack >= 1.7.0.
193
1942.  Change to the pandoc source directory and issue the following commands:
195
196        stack setup
197        stack install
198
199    `stack setup` will automatically download the ghc compiler
200    if you don't have it.  `stack install` will install the
201    `pandoc` executable into `~/.local/bin`, which you should
202    add to your `PATH`.  This process will take a while, and
203    will consume a considerable amount of disk space.
204
205### Quick cabal method
206
2071.  Install the [Haskell platform].  This will give you [GHC] and
208    the [cabal-install] build tool.  Note that pandoc requires
209    GHC >= 7.10 and cabal >= 2.0.
210
2112.  Update your package database:
212
213        cabal update
214
2153.  Check your cabal version with
216
217        cabal --version
218
219    If you have a version less than 2.0, install the latest with:
220
221        cabal install cabal-install
222
2234.  Use `cabal` to install pandoc and its dependencies:
224
225        cabal install pandoc
226
227    This procedure will install the released version of pandoc,
228    which will be downloaded automatically from HackageDB.
229
230    If you want to install a modified or development version
231    of pandoc instead, switch to the source directory and do
232    as above, but without the 'pandoc':
233
234        cabal install
235
2365.  Make sure the `$CABALDIR/bin` directory is in your path.  You should
237    now be able to run `pandoc`:
238
239        pandoc --help
240
241    [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)
242
2435.  By default `pandoc` uses the "i;unicode-casemap" method
244    to sort bibliography entries (RFC 5051).  If you would like to
245    use the locale-sensitive unicode collation algorithm instead,
246    specify the `icu` flag (which affects the dependency `citeproc`):
247
248        cabal install pandoc -ficu
249
250    Note that this requires the `text-icu` library, which in turn
251    depends on the C library `icu4c`.  Installation directions
252    vary by platform.  Here is how it might work on macOS with Homebrew:
253
254        brew install icu4c
255        stack install pandoc \
256          --flag "citeproc:icu" \
257          --extra-lib-dirs=/usr/local/opt/icu4c/lib \
258          --extra-include-dirs=/usr/local/opt/icu4c/include
259
2606.  The `pandoc.1` man page will be installed automatically.  cabal shows
261    you where it is installed: you may need to set your `MANPATH`
262    accordingly. If `MANUAL.txt` has been modified, the man page can be
263    rebuilt: `make man/pandoc.1`.
264
265
266### Custom cabal method
267
268This is a step-by-step procedure that offers maximal control
269over the build and installation.  Most users should use the
270quick install, but this information may be of use to packagers.
271For more details, see the [Cabal User's Guide].  These instructions
272assume that the pandoc source directory is your working directory.
273You will need cabal version 2.0 or higher.
274
2751.  Install dependencies:  in addition to the [Haskell platform],
276    you will need a number of additional libraries.  You can install
277    them all with
278
279        cabal update
280        cabal install --only-dependencies
281
2822.  Configure:
283
284        cabal configure --prefix=DIR --bindir=DIR --libdir=DIR \
285          --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \
286          --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \
287          --mandir=DIR --flags=FLAGSPEC --enable-tests
288
289    All of the options have sensible defaults that can be overridden
290    as needed.
291
292    `FLAGSPEC` is a list of Cabal configuration flags, optionally
293    preceded by a `-` (to force the flag to `false`), and separated
294    by spaces.  Pandoc's flags include:
295
296    - `embed_data_files`: embed all data files into the binary (default no).
297      This is helpful if you want to create a relocatable binary.
298
299    - `https`:  enable support for downloading resources over https
300      (using the `http-client` and `http-client-tls` libraries).
301
3023.  Build:
303
304        cabal build
305        cabal test
306
3074.  Build API documentation:
308
309        cabal haddock --html-location=URL --hyperlink-source
310
3115.  Copy the files:
312
313        cabal copy --destdir=PATH
314
315    The default destdir is `/`.
316
3176.  Register pandoc as a GHC package:
318
319        cabal register
320
321    Package managers may want to use the `--gen-script` option to
322    generate a script that can be run to register the package at
323    install time.
324
325### Creating a relocatable binary
326
327It is possible to compile pandoc such that the data files
328pandoc uses are embedded in the binary.  The resulting binary
329can be run from any directory and is completely self-contained.
330With cabal, add `-fembed_data_files` to the `cabal configure`
331or `cabal install` commands.
332
333With stack, use `--flag pandoc:embed_data_files`.
334
335
336
337### Running tests
338
339Pandoc comes with an automated test suite.
340To run with cabal, `cabal test`; to run with stack, `stack
341test`.
342
343To run particular tests (pattern-matching on their names), use
344the `-p` option:
345
346    cabal install pandoc --enable-tests
347    cabal test --test-options='-p markdown'
348
349Or with stack:
350
351    stack test --test-arguments='-p markdown'
352
353It is often helpful to add `-j4` (run tests in parallel)
354and `--hide-successes` (don't clutter output with successes)
355to the test arguments as well.
356
357If you add a new feature to pandoc, please add tests as well, following
358the pattern of the existing tests. The test suite code is in
359`test/test-pandoc.hs`. If you are adding a new reader or writer, it is
360probably easiest to add some data files to the `test` directory, and
361modify `test/Tests/Old.hs`. Otherwise, it is better to modify the module
362under the `test/Tests` hierarchy corresponding to the pandoc module you
363are changing.
364
365### Running benchmarks
366
367To build and run the benchmarks:
368
369    cabal configure --enable-benchmarks && cabal build
370    cabal bench
371
372or with stack:
373
374    stack bench
375
376To use a smaller sample size so the benchmarks run faster:
377
378    cabal bench --benchmark-options='-s 20'
379
380To run just the markdown benchmarks:
381
382    cabal bench --benchmark-options='markdown'
383
384
385[Arch]: https://www.archlinux.org/packages/community/x86_64/pandoc/
386[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths
387[Debian]: https://packages.debian.org/pandoc
388[Fedora]: https://apps.fedoraproject.org/packages/pandoc
389[FreeBSD ports]: http://www.freshports.org/textproc/hs-pandoc/
390[GHC]:  http://www.haskell.org/ghc/
391[GPL]:  http://www.gnu.org/copyleft/gpl.html
392[Haskell platform]: http://hackage.haskell.org/platform/
393[MacPorts]: http://trac.macports.org/browser/trunk/dports/textproc/pandoc/Portfile
394[MacTeX]: https://tug.org/mactex/
395[BasicTeX]: http://www.tug.org/mactex/morepackages.html
396[LaTeX]: https://www.latex-project.org
397[MiKTeX]: http://miktex.org/
398[librsvg]: https://wiki.gnome.org/Projects/LibRsvg
399[Python]: https://www.python.org
400[NetBSD]: http://pkgsrc.se/wip/pandoc
401[NixOS]: https://nixos.org/nixos/packages.html
402[Slackware]: https://www.slackbuilds.org/result/?search=pandoc&sv=
403[Ubuntu]: https://packages.ubuntu.com/pandoc
404[download page]: https://github.com/jgm/pandoc/releases/latest
405[gentoo]: http://packages.gentoo.org/package/app-text/pandoc
406[haskell repository]: https://wiki.archlinux.org/index.php/Haskell_Package_Guidelines#.5Bhaskell.5D
407[openSUSE]: https://software.opensuse.org/package/pandoc
408[source tarball]: http://hackage.haskell.org/package/pandoc
409[stack]: https://docs.haskellstack.org/en/stable/install_and_upgrade.html
410[cabal-install]: http://hackage.haskell.org/package/cabal-install
411[Void]: https://voidlinux.org/
412[uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/macos/uninstall-pandoc.pl
413