-
-
Notifications
You must be signed in to change notification settings - Fork 3
Installing Pandoc
Pandoc is a universal document converter that allows you to convert between various markup formats such as Markdown, LaTeX, HTML, and more. This guide provides two ways to install Pandoc:
- Manual Installation: Installing Pandoc using package managers.
- Automated Installation: Using a Bash script to check for Pandoc and install it if necessary.
Run the following command to install Pandoc:
sudo apt update && sudo apt install -y pandocFor Arch-based distributions, use pacman:
sudo pacman -Syu --noconfirm pandocFor macOS users, install Pandoc using Homebrew:
brew install pandocIf Homebrew is not installed, you can install it by following the instructions at Homebrew's official website.
Download and install Pandoc from the official site: Pandoc Downloads
Instead of manually installing Pandoc, you can use the following Bash script to check for Pandoc and install it automatically based on your OS.
Save the following script as install-pandoc.sh:
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Pandoc is installed
if command_exists pandoc; then
echo "Pandoc is already installed: $(pandoc --version | head -n 1)"
exit 0
fi
echo "Pandoc is not installed. Attempting to install it..."
# Detect the package manager and install Pandoc
if [[ -f /etc/debian_version ]]; then
# Debian-based (Ubuntu, Debian)
sudo apt update && sudo apt install -y pandoc
elif [[ -f /etc/arch-release ]]; then
# Arch Linux
sudo pacman -Syu --noconfirm pandoc
elif [[ "$(uname)" == "Darwin" ]]; then
# macOS
if command_exists brew; then
brew install pandoc
else
echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
exit 1
fi
else
echo "Unsupported operating system. Please install Pandoc manually: https://pandoc.org/installing.html"
exit 1
fi
# Verify if the installation was successful
if command_exists pandoc; then
echo "Pandoc successfully installed: $(pandoc --version | head -n 1)"
else
echo "Pandoc installation failed. Please try installing it manually."
exit 1
fiTo execute the script, follow these steps:
-
Make the script executable:
chmod +x install-pandoc.sh
-
Run the script:
./install-pandoc.sh
The script will check if Pandoc is installed and install it using the appropriate package manager.
This guide provides both a manual and an automated way to install Pandoc on Linux and macOS. The automated script ensures that installation is handled efficiently, reducing the need for manual intervention.