thibaud frere commited on
Commit ·
aa8b9d7
1
Parent(s): 36a0415
add dev mode and CD for latex support
Browse filesFiles changed (7)
1 unmodified line2345678910 unmodified lines2021222324251 unmodified line# Build with Playwright (browsers and deps ready)FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build# Install git and git-lfs for handling LFS filesRUN apt-get update && apt-get install -y git git-lfs && apt-get clean# Set the working directory in the containerWORKDIR /workspace10 unmodified lines# Install dependenciesRUN npm install# Ensure `public/data` is a real directory with real files (not a symlink)# This handles the case where `public/data` is a symlink in the repo, which# would be broken inside the container after COPY.1 unmodified line2345678910 unmodified lines2021222324252627281 unmodified line# Build with Playwright (browsers and deps ready)FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build# Install git, git-lfs, and pandoc for handling LFS files and LaTeX conversionRUN apt-get update && apt-get install -y git git-lfs pandoc && apt-get clean# Set the working directory in the containerWORKDIR /workspace10 unmodified lines# Install dependenciesRUN npm install# Convert LaTeX to MDX before buildingRUN npm run latex:convert# Ensure `public/data` is a real directory with real files (not a symlink)# This handles the case where `public/data` is a symlink in the repo, which# would be broken inside the container after COPY.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475# 📚 LaTeX to MDX Integration
Cette intégration permet de convertir automatiquement des sources LaTeX en MDX pour Astro, avec surveillance en temps réel des changements.
## 🚀 Utilisation
### Mode Développement avec LaTeX Watch
```bash# Démarre le serveur de développement avec surveillance LaTeXnpm run dev:with-latex```
Cette commande :1. ✅ Convertit initialement LaTeX → MDX2. 🔄 Surveille `scripts/latex-to-mdx/input/` pour les changements3. 🌐 Lance le serveur Astro sur http://localhost:43214. 📝 Régénère automatiquement `article.mdx` lors de modifications
### Mode Production
```bash# Build de production (convertit LaTeX puis build Astro)npm run build```
### Scripts Individuels
```bash# Conversion unique LaTeX → MDXnpm run latex:convert
# Surveillance LaTeX uniquementnpm run latex:watch
# Développement Astro classique (sans LaTeX)npm run dev```
## 📁 Structure LaTeX
Place tes sources LaTeX dans :```app/scripts/latex-to-mdx/input/├── main.tex # Document principal├── main.bib # Bibliographie ├── sections/ # Chapitres/sections│ ├── 01_introduction.tex│ ├── 02_methods.tex│ └── ...├── figures/ # Images└── ... # Autres fichiers LaTeX```
## ⚙️ Fonctionnalités
- 🔄 **Conversion automatique** : 2 secondes par conversion- 📊 **Surveillance complète** : Tout le dossier `input/`- 🎯 **Intégration Docker** : Pandoc installé automatiquement- 🌐 **Hot reload** : Astro recharge automatiquement après conversion- 📝 **Logs colorés** : Différenciation LaTeX/Astro dans la console
## 🐳 Docker
Le Dockerfile inclut maintenant :- Installation automatique de Pandoc- Conversion LaTeX → MDX avant le build Astro- Support complet de l'environnement LaTeX
## 🛠️ Debugging
Si la conversion échoue :1. Vérifier les logs LaTeX (en bleu)2. Vérifier que Pandoc est installé3. Tester la conversion manuelle : `npm run latex:convert`123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101#!/usr/bin/env node
import { spawn } from 'child_process';import { join, dirname } from 'path';import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);
console.log('🚀 Starting development server with LaTeX watching...\n');
// Function to start a processfunction startProcess(command, args, cwd, name, color) { const process = spawn(command, args, { cwd, stdio: 'pipe', shell: true });
// Color codes const colors = { reset: '\x1b[0m', bright: '\x1b[1m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m' };
const prefix = `${colors[color]}[${name}]${colors.reset}`;
process.stdout.on('data', (data) => { const lines = data.toString().split('\n').filter(line => line.trim()); lines.forEach(line => { console.log(`${prefix} ${line}`); }); });
process.stderr.on('data', (data) => { const lines = data.toString().split('\n').filter(line => line.trim()); lines.forEach(line => { console.log(`${prefix} ${colors.red}${line}${colors.reset}`); }); });
process.on('close', (code) => { console.log(`${prefix} ${colors.red}Process exited with code ${code}${colors.reset}`); });
return process;}
// Initial LaTeX conversionconsole.log('📚 Converting LaTeX to MDX initially...');const initialConvert = spawn('npm', ['run', 'latex:convert'], { cwd: join(__dirname, '..'), stdio: 'inherit'});
initialConvert.on('close', (code) => { if (code === 0) { console.log('✅ Initial LaTeX conversion completed!\n');
// Start LaTeX watcher const latexWatcher = startProcess( 'npm', ['run', 'latex:watch'], join(__dirname, '..'), 'LaTeX', 'blue' );
// Start Astro dev server const astroServer = startProcess( 'npm', ['run', 'dev'], join(__dirname, '..'), 'Astro', 'green' );
// Handle graceful shutdown process.on('SIGINT', () => { console.log('\n🛑 Shutting down development servers...'); latexWatcher.kill(); astroServer.kill(); process.exit(0); });
console.log('🎉 Development environment ready!'); console.log(' 📝 LaTeX files: Watch mode active for scripts/latex-to-mdx/input/'); console.log(' 🌐 Astro server: http://localhost:4321'); console.log(' 🔄 Any change in LaTeX input/ will auto-regenerate MDX\n');
} else { console.error('❌ Initial LaTeX conversion failed!'); process.exit(1); }});137 unmodified lines138139140141142143144145146147148149137 unmodified linesshowtabs=false,tabsize=2}\lstset{style=mycodestyle}\usepackage{setspace}\usepackage{nicematrix}\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}137 unmodified lines138139140141142143144145146147148149137 unmodified linesshowtabs=false,tabsize=2}\lstset{style=mycodestyle}\usepackage{setspace}\usepackage{nicematrix}\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
Dockerfile+5-2
README-latex-integration.mdAdded+75
app/package.json
app/scripts/dev-with-latex.mjsAdded+101
app/scripts/latex-to-mdx/input/main.tex+2-2
app/scripts/latex-to-mdx/package-lock.json
app/src/content/article.mdx