hykocx 0f09b30164 feat: add markdown-to-pdf converter with Puppeteer
Introduce a Node.js CLI tool that converts Markdown files to styled
PDFs using `marked` for parsing and `puppeteer` for rendering.

- Add `md-to-pdf.js` as the main conversion script with:
  - CLI argument handling for input/output file paths
  - Automatic output directory creation alongside the input file
  - Pre-processing to strip thematic breaks (`---`) before headings
  - Embedded CSS for clean, print-ready styling (headings, tables,
    code blocks, blockquotes, page breaks, etc.)
  - PDF generation via Puppeteer with A4 format and custom margins
- Add `.gitignore` to exclude `node_modules/` and `output/` directories
- Add `package-lock.json` with resolved dependencies (marked, puppeteer)
2026-04-15 11:28:16 -04:00

markdown-to-pdf

Convertit un fichier Markdown en PDF bien mis en forme — fond blanc, typographie soignée, sans coupures de page au milieu des tableaux ou des blocs de code.

Installation

npm install

Utilisation

node md-to-pdf.js <fichier.md>

Le PDF est généré dans output/<fichier>.pdf, à côté du fichier source. Le dossier output/ est créé automatiquement s'il n'existe pas.

Un chemin de sortie personnalisé peut être fourni en second argument :

node md-to-pdf.js rapport.md /tmp/rapport.pdf

Fonctionnalités

  • Tableaux, blocs de code, citations et images jamais coupés entre deux pages
  • Les titres ne se retrouvent pas seuls en bas de page
  • Lignes alternées sur les tableaux
  • Code inline et en blocs avec police monospace et fond discret
  • Citations avec bordure bleue à gauche
  • Format A4 avec marges adaptées

Dépendances

Package Rôle
marked Markdown → HTML
puppeteer HTML → PDF via Chromium headless
S
Description
Convertit un fichier Markdown en PDF bien mis en forme.
Readme 47 KiB
Languages
JavaScript 100%