# How to Install Pandoc on CentOS 7

Posted on by Misael Ramirez

## What is Pandoc?

Pandoc is an open source command-line utility that serves as a format converter, changing files between markup languages. It was created in 2006 by John MacFarlane and written in Haskell. This tool is compatible with Windows, CentOS, and most Unix-like systems.

A markup language is an annotation system used to format text in a visually distinctive way. In short, markup languages are vital in making the Internet pretty.

Here are some examples of markup languages:

• HTML
• XML
• Markdown (considered lightweight markup)

A great tool to use when dealing with several files using different formats is Pandoc.

The goal of Pandoc is to only convert the markup of any given document without modifying its source content. This article will provide an overview of how to install Pandoc on CentOS 7 (also valid for Red Hat Enterprise Linux), along with some basic usage examples.

## How to Install Pandoc

### Requirements

Before starting with the installation process, there are a few requirements necessary for a successful procedure.

• SSH access.
• Root privileges.
• The Extra Packages for Enterprise Linux (EPEL) repository.

### Step 1. Getting Ready to Install Pandoc

Verify the local packages are updated.

LiquidWeb_Centos # sudo yum update
No packages marked for update

Install EPEL if it is missing.

LiquidWeb_Centos # yum install epel-release
...
Installed:
epel-release.noarch 0:7-11
Complete!

Verify that the repository was added correctly.

LiquidWeb_Centos # yum repolist
...
epel/x86_64    Extra Packages for Enterprise Linux 7 - x86_64

### Step 2. Installing the Pandoc Package

When installing the Pandoc package, there are several dependencies needed for it to work correctly. Accept the installation to complete the process.

LiquidWeb_Centos # yum install pandoc

Once complete, it produces an output similar to the image below.

### Step 3. Verify the Version of Pandoc

Use the following command to check the version of Pandoc.

LiquidWeb_Centos # pandoc -v
pandoc 1.12.3.1
Compiled with texmath 0.6.6, highlighting-kate 0.5.6.
...
This is free software; see the source for copying conditions.  There is no
warranty, not even for merchantability or fitness for a particular purpose.

### Use Cabal to Install Pandoc

Alternatively, we can use Cabal, a package manager for Haskell libraries and programs, to install Pandoc.

LiquidWeb_Centos # cabal install pandoc

## Basic Usage

The usage of Pandoc is relatively simple, with a standard format. We can use the --help tag or review the man pages to get more insights into all the supported formats, but we’ll usually use the below syntax.

pandoc -s -f INPUT_FORMAT -t OUTPUT_FORMAT FILE_TO_CONVERT -o OUTPUT_FILE
• -s (standalone): Produces output with the necessary metadata according to the output format.
• -f (from): Specify the input format.
• -t (to): Specify the output format.
• -o (output): Specifies a new file containing the results of the conversion.

By default, Pandoc sends the converted file to stdout. So, if no output file is specified, it will print the conversion results on the terminal.

For example, say we want to convert the file test.html to plain text. In this case, it will convert the document to a .txt file. Here are the file contents shown within the terminal.

LiquidWeb_Centos # cat test.html
<!DOCTYPE html>
<html>
<body>

<h1>A random title</h1>
<p>Some random text!</p>

</body>
</html>

To convert the document, use the below command. Here, we specified that the input format was HTML and the output plain text.

LiquidWeb_Centos # pandoc -s -f html -t plain test.html -o test.txt

The output redirects to a new file called test.txt.

LiquidWeb_Centos # cat test.txt
A random title
==============

Some random text!

Additionally, external sources can be used in place of local files. For example, to convert the index of a website to markdown and print the output to the terminal (omitting the -o tag), use the following syntax.

LiquidWeb_Centos # pandoc -s -f html -t markdown http://pandoc.domain.com
Fetching http://pandoc.domain.com...
This is a test

Just testing some things out!
=============================

Thank you!

— The Team

Another exciting feature is that Pandoc tries to guess the input format from the file extensions when missing. So, for example, here is what it looks like converting a LaTeX document to AsciiDoc.

LiquidWeb_Centos # cat  document.tex
\documentclass[14pt]{article}
\usepackage{lingmacros}
\usepackage{tree-dvips}
\begin{document}

\section*{Various notes}

\subsection*{How to write a paper}

Here it begins (\ex{1}).

{\small
\enumsentence{Structure of A$'$ Projections:\\ [2ex]
\begin{tabular}[t]{cccc}
& \node{i}{CP}\\ [2ex]
\node{ii}{Spec} &   &\node{iii}{C$'$}\\ [2ex]
&\node{iv}{C} & & \node{v}{SAgrP}
\end{tabular}
\nodeconnect{i}{ii}
\nodeconnect{i}{iii}
\nodeconnect{iii}{iv}
\nodeconnect{iii}{v}
}
}

\subsection*{Another topic}

Proin enim sem, varius sed finibus sit amet, porttitor eu neque. Curabitur hendrerit rhoncus nibh, eget varius purus finibus sit amet.

\end{document}

Now, convert this document and check the contents of the newly generated file.

LiquidWeb_Centos # pandoc -s -t asciidoc document.tex -o document.txt
LiquidWeb_Centos # cat document.txt
[[various-notes]]
Various notes
-------------

[[how-to-write-a-paper]]
How to write a paper
~~~~~~~~~~~~~~~~~~~~

Here it begins ().

[[another-topic]]
Another topic
~~~~~~~~~~~~~

Proin enim sem, varius sed finibus sit amet, porttitor eu neque.
Curabitur hendrerit rhoncus nibh, eget varius purus finibus sit amet.

As you can see, Pandoc is a powerful tool for converting markup to plain text with no compromises to the document.

## Conclusion

The flexibility of Pandoc is vast, and the range of applications can make a difference compared to not using this tool. The scope of this article was to cover the basics and the process of how to install Pandoc. Still, there are more advanced options, such as adding plugins for custom formats, or support for ebooks and PDF documents, opening an entirely new world of use cases.

For 24-hour assistance any day of the year, contact one of Liquid Web’s Most Helpful Humans in Hosting. We are here to help!

## About the Author: Misael Ramirez

A former support technician, I have a degree in mechatronics; the career suited me because I'm always trying new things. I have a wide range of interests, but mainly I love music, movies (old ones), and physics.

## Latest Articles

What Is Umask and How to Use it Effectively

Troubleshooting: Too Many Redirects