md2html
Convertit automatiquement un rapport Markdown interne en page HTML professionnelle hébergée sur le réseau Tailscale. Utilise pandoc (ou python-markdown en fallback) localement — zéro token consommé. Déclencher après toute génération de fichier .md interne (rapport, audit, veille, synthèse). Produit un lien HTML cliquable et écrit le fichier dans ~/rapports-html/. Accessible via http://mx.home/rapports/ et http://mx.tailaa682b.ts.net/ depuis toutes les machines Tailscale.
Quand l'utiliser (Trigger)
agent produit un fichier .md de rapport final; commande "convertir en HTML"; commande "publier rapport"; fin d'un pipeline générant un .md (veille, audit, évaluation)
Mode d'emploi (Usage)
Mode d'emploi standard via l'agent Hermès. md2html — Convertisseur Markdown → HTML (interne Tailscale)
Objectif
Transformer tout rapport .md interne en page HTML professionnelle autonome, sans consommer de tokens IA. Accessible depuis toutes les machines du réseau Tailscale.
Accès réseau
| Endpoint | URL | Notes |
|---|---|---|
| MX (local) | http://mx.home/rapports/<fichier>.html | via nginx (après setup.sh) |
| MX (Tailscale) | http://mx.tailaa682b.ts.net/<fichier>.html | via tailscale serve, actif maintenant |
| VPS | http://vps.home/rapports/<fichier>.html | via nginx (après setup.sh sudo) |
| VPS (Tailscale) | http://vps.tailaa682b.ts.net/<fichier>.html | après setup.sh —operator=bf |
Usage
Conversion simple
md2html rapport.md
# → [HTML] http://mx.home/rapports/rapport.html
# → [FILE] /home/bf/rapports-html/rapport.html
Avec URL personnalisée
md2html rapport.md --base-url http://mx.tailaa682b.ts.net
Sortie dans un dossier spécifique
md2html input.md /var/www/rapports/output.html
En Python (dans un script)
import subprocess
subprocess.run(['md2html', chemin_md])
# Ou directement:
from md2html import convert
convert('/path/to/rapport.md')
Features HTML générées
- Dark/Light mode : toggle manuel + détection système
- TOC : table des matières auto-générée depuis H2/H3, sticky sidebar ≥1100px
- Coloration syntaxique : thème breezedark (pandoc) sur tous les blocs code
- Tables responsives : wrapper overflow-x auto
- Scroll progress bar : barre 3px en haut de page
- Anchor links :
#clickable sur H2/H3 au survol - Footer : timestamp + chemin du fichier source
- CSS embarqué : fichier HTML autonome, portable, sans dépendances externes
Infrastructure (MX)
- Fichiers HTML :
~/rapports-html/ - Serveur web user :
systemctl --user status rapports-web(port 8765, bind 127.0.0.1) - Tailscale serve :
tailscale serve status→ http://mx.tailaa682b.ts.net → 8765 - Script :
~/.local/bin/md2html→~/Bureau/projets-dev/md2html/md2html.py - Setup nginx+DNS (sudo requis 1 fois) :
~/Bureau/projets-dev/md2html/setup.sh
Infrastructure (VPS)
- Fichiers HTML :
~/rapports-html/ - Serveur web user :
systemctl --user status rapports-web(port 8765) - Script :
~/bin/md2html.py - Tailscale serve : nécessite
sudo tailscale set --operator=bf(dans setup.sh)
Directive pour agents producteurs de rapports
Tout agent ou script générant un fichier .md interne DOIT appeler md2html à la fin.
Intégration bash (à ajouter en fin de script) :
if command -v md2html &>/dev/null; then
md2html "$OUTPUT_FILE" && echo "→ Rapport HTML disponible ci-dessus"
fi
Intégration python :
import subprocess
subprocess.run(['md2html', str(output_path)], check=False)
Scripts intégrés (Phase 5)
| Script | Rapport .md | Intégration |
|---|---|---|
~/Bureau/projets-dev/TutoIA/scripts/veille-agent.sh | YYYY-MM-DD-veille-ia.md | wrapper post-script |
~/real-scraper/agents/reporting_agent.py | rapport_reprises_*.md | appel subprocess fin de run |
~/.hermes/scripts/task-observer-weekly.sh | review-YYYY-MM-DD.md | ligne ajoutée en fin |
~/.hermes/scripts/pipeline-evaluation.sh | plan.md, audit.md, decision.md | appel en fin de pipeline |
VPS: /home/bf/tutoia/scripts/veille-agent.sh | YYYY-MM-DD-veille-ia.md | wrapper |
Désactivation
# Arrêter le serveur web (temporaire)
systemctl --user stop rapports-web
# Retirer tailscale serve
tailscale serve --http=80 off
# Réactiver
systemctl --user start rapports-web
tailscale serve --bg --http=80 localhost:8765