Pandoc

Posted on sam. 24 novembre 2018 in Documentation

a universal document converter

Introduction

Pandoc can convert documents in markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, TWiki markup, OPML, Emacs Org-Mode, Txt2Tags, Microsoft Word docx, LibreOffice ODT, EPUB, or Haddock markup to HTML formats, Word processor formats, Ebooks, Documentation formats, InDesign ICML, OPML, LaTeX, ConTeXt, LaTeX Beamer slides, PDF or Lightweight markup formats.

Installation

*nix

apt install texlive-latex-recommended pandoc
# or
dnf install pandoc texlive-latex

Windows

http://miktex.org/download

https://github.com/jgm/pandoc/releases/latest

Utilisation

Makefile

récupérable ici : https://gist.github.com/Darkitty/258826aac448a522d1a4e5199b316405

Traite l'ensemble des fichiers en extension md vers des fichiers PDF avec la prise en charge de la coloration syntaxique.

# Produce PDFs from all Markdown files in a directory

# List files to be made by finding all *.md files and appending .pdf
PDFS := $(patsubst %.md,%.pdf,$(wildcard *.md))

# The all rule makes all the PDF files listed
all : $(PDFS)

# This generic rule accepts PDF targets with corresponding Markdown 
# source, and makes them using pandoc
%.pdf : %.md
        # Conversion to PDF file
        pandoc -V geometry:paperwidth=21cm -V geometry:paperheight=29.4cm -V geometry:margin=.5cm --highlight-style tango --tos -f markdown $< -o $@

# Remove all PDF outputs
clean :
        rm $(PDFS)

# Remove all PDF outputs then build them again
rebuild : clean all

pandoc --listings -H listings-setup.tex --toc -V geometry:"left=1cm, top=1cm, right=1cm, bottom=2cm" .\README.md -o .\README.pdf