A professional, batteries-included CLI tool for converting Markdown documents to PDF, DOCX, HTML, and more using pandoc.
- π― Simple CLI interface - Intuitive flags and options
- π Flexible margins - Set individual or uniform margins
- π¨ Multiple output formats - PDF, DOCX, HTML, EPUB, and more
- π€ Auto-setup - Installs dependencies on first run
- π¨ Colorized output - Beautiful, readable terminal output
- π Dry-run mode - Preview conversions before running
- π Verbose mode - Detailed output for debugging
- β‘ Batch processing - Easy to use in loops
- π‘οΈ Safe by default - Won't overwrite files without
-f - π Zero configuration - Works out of the box
The easiest way to install and keep doc-conv up to date:
# Install from custom tap
brew install liiam-dsouza/tap/doc-conv
# Run setup to install dependencies
doc-conv --setupUpdating:
brew upgrade doc-convUninstalling:
brew uninstall doc-convQuick installation for any Unix-like system:
curl -fsSL https://raw.githubusercontent.com/liiam-dsouza/doc-conv/main/install.sh | bashFor cautious users (review before running):
# Download the installer
curl -fsSL https://raw.githubusercontent.com/liiam-dsouza/doc-conv/main/install.sh -o install.sh
# Review it
less install.sh
# Run it
bash install.sh
# Clean up
rm install.shCustom installation directory:
INSTALL_DIR=$HOME/.local/bin curl -fsSL https://raw.githubusercontent.com/liiam-dsouza/doc-conv/main/install.sh | bashDownload the latest release directly:
# Download latest version
curl -L https://github.com/liiam-dsouza/doc-conv/releases/latest/download/doc-conv -o doc-conv
# Make executable
chmod +x doc-conv
# Move to PATH (choose one)
sudo mv doc-conv /usr/local/bin/ # System-wide
mv doc-conv ~/.local/bin/ # User-only (add to PATH if needed)
# Verify installation
doc-conv --versionSpecific version:
VERSION=1.0.0
curl -L https://github.com/liiam-dsouza/doc-conv/releases/download/v${VERSION}/doc-conv -o doc-conv
chmod +x doc-conv
sudo mv doc-conv /usr/local/bin/For contributors or those who want the latest unreleased features:
# Clone the repository
git clone https://github.com/liiam-dsouza/doc-conv.git
cd doc-conv
# Make executable
chmod +x doc-conv
# Install (choose one)
sudo cp doc-conv /usr/local/bin/ # System-wide
cp doc-conv ~/.local/bin/ # User-only
# Or create a symlink for development
ln -s $(pwd)/doc-conv /usr/local/bin/doc-conv
# Run setup
doc-conv --setupAfter installation, run the setup wizard to install dependencies:
doc-conv --setupThis will check for and optionally install:
- pandoc - Document converter (required)
- BasicTeX/LaTeX - For PDF generation (optional but recommended)
Dependencies are only installed with your permission!
# Convert Markdown to PDF
doc-conv input.md pdf
# Convert to Word
doc-conv input.md docx
# Convert to HTML
doc-conv input.md html# All margins the same
doc-conv -m 2cm input.md pdf
# Individual margins (top, right, bottom, left)
doc-conv -t 1.5in -r 1in -b 1.5in -l 1in input.md pdf# Custom output filename
doc-conv -o final-report.pdf input.md pdf
# Output to specific directory
doc-conv -d ./output input.md pdf
# Overwrite existing files
doc-conv -f input.md pdf
# Preview without converting (dry run)
doc-conv --dry-run input.md pdf
# Verbose output for debugging
doc-conv --verbose input.md pdf# Narrow margins for academic journals
doc-conv -m 0.75in thesis.md pdf# Standard 1-inch margins
doc-conv -m 1in proposal.md pdf# Convert to HTML
doc-conv article.md html# Convert to EPUB
doc-conv book.md epub# Convert all Markdown files to PDF
for file in *.md; do
doc-conv "$file" pdf
done
# Convert with custom margins to output directory
for file in *.md; do
doc-conv -m 2cm -d ./pdfs "$file" pdf
done
# Convert only if PDF doesn't exist
for file in *.md; do
[[ ! -f "${file%.md}.pdf" ]] && doc-conv "$file" pdf
done# Makefile
%.pdf: %.md
doc-conv -m 1in $< pdf
all: $(patsubst %.md,%.pdf,$(wildcard *.md))
clean:
rm -f *.pdf
.PHONY: all clean| Option | Description |
|---|---|
-h, --help |
Show help message and exit |
-v, --version |
Show version information |
--setup |
Run setup/dependency installer |
| Option | Description | Example |
|---|---|---|
-m, --margin SIZE |
Set all margins | -m 2cm |
-t, --top SIZE |
Set top margin | -t 1.5in |
-r, --right SIZE |
Set right margin | -r 1in |
-b, --bottom SIZE |
Set bottom margin | -b 1.5in |
-l, --left SIZE |
Set left margin | -l 1in |
Supported units: in (inches), cm (centimeters), mm (millimeters), pt (points)
Default: All margins default to 1in if not specified
| Option | Description | Example |
|---|---|---|
-o, --output FILE |
Custom output filename | -o report.pdf |
-d, --dir DIR |
Output directory | -d ./output |
-f, --force |
Overwrite existing files | -f |
| Option | Description |
|---|---|
--dry-run |
Preview conversion without executing |
--verbose |
Show detailed output and pandoc messages |
--no-color |
Disable colored terminal output |
Optimized for Markdown (.md) files with full GitHub Flavored Markdown support.
| Format | Extension | Description | Notes |
|---|---|---|---|
| π PDF | .pdf |
Portable Document Format | Requires LaTeX |
| π DOCX | .docx |
Microsoft Word | Full formatting support |
| π HTML | .html |
Web page | Standalone or fragment |
| π EPUB | .epub |
E-book | Reflowable layout |
| π LaTeX | .tex |
LaTeX source | For further customization |
| π RTF | .rtf |
Rich Text Format | Cross-platform |
| π ODT | .odt |
OpenDocument Text | LibreOffice compatible |
| π° RST | .rst |
reStructuredText | Documentation |
| π ORG | .org |
Emacs Org-mode | Plain text |
And many more supported by pandoc!
Add these to your ~/.zshrc or ~/.bashrc:
# Quick PDF conversion with 2cm margins
alias md2pdf='doc-conv -m 2cm'
# Convert and open immediately (macOS)
md2pdf-open() {
doc-conv "$1" pdf && open "${1%.md}.pdf"
}
# Convert and open immediately (Linux)
md2pdf-open() {
doc-conv "$1" pdf && xdg-open "${1%.md}.pdf"
}
# Batch convert all MD files in current directory
alias md2pdf-all='for f in *.md; do doc-conv "$f" pdf; done'Automatically generate PDFs when committing:
#!/bin/bash
# .git/hooks/pre-commit
# Convert any modified .md files to PDF
for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.md$'); do
if [ -f "$file" ]; then
echo "Generating PDF for $file..."
doc-conv "$file" pdf
git add "${file%.md}.pdf"
fi
doneAuto-convert when files change:
# Install fswatch (macOS)
brew install fswatch
# Watch and auto-convert
fswatch -o *.md | xargs -n1 -I{} sh -c 'doc-conv $(ls *.md | head -1) pdf'
# Or use entr (cross-platform)
ls *.md | entr doc-conv /_ pdfFor advanced users who need custom pandoc options, you can modify the script or use pandoc directly with doc-conv's margin calculation:
# Get the geometry string from doc-conv dry run
doc-conv --dry-run -m 2cm input.md pdf
# Use it with pandoc directly
pandoc input.md -o output.pdf --pdf-engine=xelatex \
-V geometry:"top=2cm,right=2cm,bottom=2cm,left=2cm" \
--toc \
--number-sectionsbrew upgrade doc-convcurl -fsSL https://raw.githubusercontent.com/liiam-dsouza/doc-conv/main/install.sh | bash# Remove old version
sudo rm /usr/local/bin/doc-conv
# Download and install new version
curl -L https://github.com/liiam-dsouza/doc-conv/releases/latest/download/doc-conv -o doc-conv
chmod +x doc-conv
sudo mv doc-conv /usr/local/bin/doc-conv --versionbrew uninstall doc-conv
rm -rf ~/.config/doc-conv # Remove config files# Remove binary
sudo rm /usr/local/bin/doc-conv
# Remove config directory (optional)
rm -rf ~/.config/doc-conv
# If installed to ~/.local/bin
rm ~/.local/bin/doc-convSolution:
doc-conv --setupOr install manually:
# macOS
brew install pandoc
# Ubuntu/Debian
sudo apt-get install pandoc
# Fedora
sudo dnf install pandocSolution:
doc-conv --setupOr install manually:
# macOS
brew install --cask basictex
# Ubuntu/Debian
sudo apt-get install texlive-xetex texlive-fonts-recommended
# Fedora
sudo dnf install texlive-xetex texlive-collection-fontsrecommendedSolution:
# Update LaTeX package manager
sudo tlmgr update --self
# Install recommended font packages
sudo tlmgr install collection-fontsrecommended
# Run with verbose output to see the error
doc-conv --verbose input.md pdfSolution:
# Make sure the script is executable
chmod +x doc-conv
# If moving to /usr/local/bin, use sudo
sudo mv doc-conv /usr/local/bin/
# Or install to user directory (no sudo needed)
mkdir -p ~/.local/bin
mv doc-conv ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH" # Add to ~/.zshrc or ~/.bashrcSolution:
Check if install directory is in your PATH:
echo $PATHIf not, add it to your shell config (~/.zshrc or ~/.bashrc):
# For /usr/local/bin (should already be in PATH)
export PATH="/usr/local/bin:$PATH"
# For ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
# Reload shell
source ~/.zshrc # or source ~/.bashrcSolution:
# Use --force flag to overwrite
doc-conv -f input.md pdf
# Or use --dry-run to check first
doc-conv --dry-run input.md pdfSolution:
# Your terminal might not support colors
# Use --no-color flag
doc-conv --no-color input.md pdf
# Or set TERM environment variable
export TERM=xterm-256colorSolution:
# Use verbose mode to see what's happening
doc-conv --verbose input.md pdf
# Check your Markdown syntax
# Try a simple test file first
echo "# Test\n\nHello world" > test.md
doc-conv test.md pdfWhen using the one-line installer, you can verify the script before running:
# Download and inspect
curl -fsSL https://raw.githubusercontent.com/liiam-dsouza/doc-conv/main/install.sh -o install.sh
# Review the code
less install.sh
# Check the hash (compare with published hash in releases)
shasum -a 256 install.sh
# Run it
bash install.shContributions are welcome! Here's how you can help:
- Check if the bug has already been reported in Issues
- If not, create a new issue with:
- Your OS and version
- doc-conv version (
doc-conv --version) - Steps to reproduce
- Expected vs actual behavior
Open an issue with the enhancement label and describe:
- The use case
- Expected behavior
- Why it would be useful
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test thoroughly
- Commit with clear messages (
git commit -m 'Add amazing feature') - Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone your fork
git clone https://github.com/YOUR_USERNAME/doc-conv.git
cd doc-conv
# Make changes
chmod +x doc-conv
# Test locally
./doc-conv --help
./doc-conv test.md pdfLiam D'Souza
- GitHub: @liiam-dsouza
- Repository: doc-conv
This tool wouldn't be possible without:
- pandoc by John MacFarlane - Universal document converter
- BasicTeX - Lightweight LaTeX distribution
- XeTeX - Unicode-based TeX typesetting engine
- Version: 1.0.0
- License: MIT
- Language: Bash
- Dependencies: pandoc, LaTeX (optional)
- Platforms: macOS, Linux, Unix-like systems
Q: Can I convert files other than Markdown?
A: Currently optimized for Markdown, but pandoc supports many input formats. You can modify the script or use pandoc directly for other formats.
Q: Do I need LaTeX for all conversions?
A: No, LaTeX is only required for PDF generation. DOCX, HTML, EPUB, etc. work without it.
Q: Can I customize the PDF styling?
A: Yes! Use custom pandoc templates or modify the script to add more pandoc options. Check the pandoc documentation for details.
Q: Does it work on Windows?
A: Not directly, but you can use WSL (Windows Subsystem for Linux).
Q: How do I report security vulnerabilities?
A: Please email security concerns privately rather than opening public issues.
Q: Can I use this in commercial projects?
A: Yes! The MIT license allows commercial use. No attribution required (but appreciated).
Q: How do I get help?
A: Open an issue on GitHub or check existing issues for solutions.
If you find doc-conv useful, please consider:
- β Starring the repository
- π¦ Sharing with others who might find it useful
- π Reporting bugs to help improve the tool
- π‘ Suggesting features for future versions
- π€ Contributing code or documentation
Every bit of support helps make doc-conv better!
Made with β€οΈ by Liam D'Souza
Last updated: 2025-11-06