Ceci est une ancienne révision du document !
md2pdf
convertir un .md en .pdf
pré-requis
md2html (convertir un .md en .html)
install
WeasyPrint
# WeasyPrint sudo apt update sudo apt install python3-pip libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b python3 -m venv weasyprint-env source weasyprint-env/bin/activate pip install weasyprint cairocffi # check install weasyprint --info
css portrait / paysage
style-paysage.css
@page { size: landscape; margin: 1cm; }
style-portrait.css
@page { size: portrait; margin: 1cm; }
html portrait / paysage
~/tpl/template-paysage.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> /* CETTE RÈGLE GARANTIT LE FORMAT PAYSAGE */ @page { size: landscape; margin: 2cm; } /* Vous pouvez ajouter d'autres styles personnalisés ici */ body { font-family: "DejaVu Sans", sans-serif; } code { font-family: "DejaVu Sans Mono", monospace; } </style> <title>$title$</title> </head> <body> $body$ </body> </html>
portrait: changer landscape en portrait
script
echo "choisir le .md à convertir en html/pdf" ls *.md read fichier echo "portrait ou paysage" read orientation pandoc $fichier -o intermediaire.html \ --~/template=~/tpl/template-$orientation.html \ --standalone weasyprint intermediaire.html $orientation.pdf