thibaud frere commited on
Commit
aa8b9d7
Β·
1 Parent(s): 36a0415

add dev mode and CD for latex support

Browse files
Dockerfile CHANGED
@@ -2,8 +2,8 @@
2
  # Build with Playwright (browsers and deps ready)
3
  FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build
4
 
5
- # Install git and git-lfs for handling LFS files
6
- RUN apt-get update && apt-get install -y git git-lfs && apt-get clean
7
 
8
  # Set the working directory in the container
9
  WORKDIR /workspace
@@ -20,6 +20,9 @@ WORKDIR /workspace/app
20
  # Install dependencies
21
  RUN npm install
22
 
 
 
 
23
  # Ensure `public/data` is a real directory with real files (not a symlink)
24
  # This handles the case where `public/data` is a symlink in the repo, which
25
  # would be broken inside the container after COPY.
 
2
  # Build with Playwright (browsers and deps ready)
3
  FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build
4
 
5
+ # Install git, git-lfs, and pandoc for handling LFS files and LaTeX conversion
6
+ RUN apt-get update && apt-get install -y git git-lfs pandoc && apt-get clean
7
 
8
  # Set the working directory in the container
9
  WORKDIR /workspace
 
20
  # Install dependencies
21
  RUN npm install
22
 
23
+ # Convert LaTeX to MDX before building
24
+ RUN npm run latex:convert
25
+
26
  # Ensure `public/data` is a real directory with real files (not a symlink)
27
  # This handles the case where `public/data` is a symlink in the repo, which
28
  # would be broken inside the container after COPY.
README-latex-integration.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ“š LaTeX to MDX Integration
2
+
3
+ Cette intΓ©gration permet de convertir automatiquement des sources LaTeX en MDX pour Astro, avec surveillance en temps rΓ©el des changements.
4
+
5
+ ## πŸš€ Utilisation
6
+
7
+ ### Mode DΓ©veloppement avec LaTeX Watch
8
+
9
+ ```bash
10
+ # DΓ©marre le serveur de dΓ©veloppement avec surveillance LaTeX
11
+ npm run dev:with-latex
12
+ ```
13
+
14
+ Cette commande :
15
+ 1. βœ… Convertit initialement LaTeX β†’ MDX
16
+ 2. πŸ”„ Surveille `scripts/latex-to-mdx/input/` pour les changements
17
+ 3. 🌐 Lance le serveur Astro sur http://localhost:4321
18
+ 4. πŸ“ RΓ©gΓ©nΓ¨re automatiquement `article.mdx` lors de modifications
19
+
20
+ ### Mode Production
21
+
22
+ ```bash
23
+ # Build de production (convertit LaTeX puis build Astro)
24
+ npm run build
25
+ ```
26
+
27
+ ### Scripts Individuels
28
+
29
+ ```bash
30
+ # Conversion unique LaTeX β†’ MDX
31
+ npm run latex:convert
32
+
33
+ # Surveillance LaTeX uniquement
34
+ npm run latex:watch
35
+
36
+ # DΓ©veloppement Astro classique (sans LaTeX)
37
+ npm run dev
38
+ ```
39
+
40
+ ## πŸ“ Structure LaTeX
41
+
42
+ Place tes sources LaTeX dans :
43
+ ```
44
+ app/scripts/latex-to-mdx/input/
45
+ β”œβ”€β”€ main.tex # Document principal
46
+ β”œβ”€β”€ main.bib # Bibliographie
47
+ β”œβ”€β”€ sections/ # Chapitres/sections
48
+ β”‚ β”œβ”€β”€ 01_introduction.tex
49
+ β”‚ β”œβ”€β”€ 02_methods.tex
50
+ β”‚ └── ...
51
+ β”œβ”€β”€ figures/ # Images
52
+ └── ... # Autres fichiers LaTeX
53
+ ```
54
+
55
+ ## βš™οΈ FonctionnalitΓ©s
56
+
57
+ - πŸ”„ **Conversion automatique** : 2 secondes par conversion
58
+ - πŸ“Š **Surveillance complΓ¨te** : Tout le dossier `input/`
59
+ - 🎯 **Intégration Docker** : Pandoc installé automatiquement
60
+ - 🌐 **Hot reload** : Astro recharge automatiquement après conversion
61
+ - πŸ“ **Logs colorΓ©s** : DiffΓ©renciation LaTeX/Astro dans la console
62
+
63
+ ## 🐳 Docker
64
+
65
+ Le Dockerfile inclut maintenant :
66
+ - Installation automatique de Pandoc
67
+ - Conversion LaTeX β†’ MDX avant le build Astro
68
+ - Support complet de l'environnement LaTeX
69
+
70
+ ## πŸ› οΈ Debugging
71
+
72
+ Si la conversion Γ©choue :
73
+ 1. VΓ©rifier les logs LaTeX (en bleu)
74
+ 2. VΓ©rifier que Pandoc est installΓ©
75
+ 3. Tester la conversion manuelle : `npm run latex:convert`
app/package.json CHANGED
Binary files a/app/package.json and b/app/package.json differ
 
app/scripts/dev-with-latex.mjs ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'child_process';
4
+ import { join, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ console.log('πŸš€ Starting development server with LaTeX watching...\n');
11
+
12
+ // Function to start a process
13
+ function startProcess(command, args, cwd, name, color) {
14
+ const process = spawn(command, args, {
15
+ cwd,
16
+ stdio: 'pipe',
17
+ shell: true
18
+ });
19
+
20
+ // Color codes
21
+ const colors = {
22
+ reset: '\x1b[0m',
23
+ bright: '\x1b[1m',
24
+ red: '\x1b[31m',
25
+ green: '\x1b[32m',
26
+ yellow: '\x1b[33m',
27
+ blue: '\x1b[34m',
28
+ magenta: '\x1b[35m',
29
+ cyan: '\x1b[36m'
30
+ };
31
+
32
+ const prefix = `${colors[color]}[${name}]${colors.reset}`;
33
+
34
+ process.stdout.on('data', (data) => {
35
+ const lines = data.toString().split('\n').filter(line => line.trim());
36
+ lines.forEach(line => {
37
+ console.log(`${prefix} ${line}`);
38
+ });
39
+ });
40
+
41
+ process.stderr.on('data', (data) => {
42
+ const lines = data.toString().split('\n').filter(line => line.trim());
43
+ lines.forEach(line => {
44
+ console.log(`${prefix} ${colors.red}${line}${colors.reset}`);
45
+ });
46
+ });
47
+
48
+ process.on('close', (code) => {
49
+ console.log(`${prefix} ${colors.red}Process exited with code ${code}${colors.reset}`);
50
+ });
51
+
52
+ return process;
53
+ }
54
+
55
+ // Initial LaTeX conversion
56
+ console.log('πŸ“š Converting LaTeX to MDX initially...');
57
+ const initialConvert = spawn('npm', ['run', 'latex:convert'], {
58
+ cwd: join(__dirname, '..'),
59
+ stdio: 'inherit'
60
+ });
61
+
62
+ initialConvert.on('close', (code) => {
63
+ if (code === 0) {
64
+ console.log('βœ… Initial LaTeX conversion completed!\n');
65
+
66
+ // Start LaTeX watcher
67
+ const latexWatcher = startProcess(
68
+ 'npm',
69
+ ['run', 'latex:watch'],
70
+ join(__dirname, '..'),
71
+ 'LaTeX',
72
+ 'blue'
73
+ );
74
+
75
+ // Start Astro dev server
76
+ const astroServer = startProcess(
77
+ 'npm',
78
+ ['run', 'dev'],
79
+ join(__dirname, '..'),
80
+ 'Astro',
81
+ 'green'
82
+ );
83
+
84
+ // Handle graceful shutdown
85
+ process.on('SIGINT', () => {
86
+ console.log('\nπŸ›‘ Shutting down development servers...');
87
+ latexWatcher.kill();
88
+ astroServer.kill();
89
+ process.exit(0);
90
+ });
91
+
92
+ console.log('πŸŽ‰ Development environment ready!');
93
+ console.log(' πŸ“ LaTeX files: Watch mode active for scripts/latex-to-mdx/input/');
94
+ console.log(' 🌐 Astro server: http://localhost:4321');
95
+ console.log(' πŸ”„ Any change in LaTeX input/ will auto-regenerate MDX\n');
96
+
97
+ } else {
98
+ console.error('❌ Initial LaTeX conversion failed!');
99
+ process.exit(1);
100
+ }
101
+ });
app/scripts/latex-to-mdx/input/main.tex CHANGED
@@ -138,12 +138,12 @@
138
  showtabs=false,
139
  tabsize=2
140
  }
141
-
142
  \lstset{style=mycodestyle}
143
 
144
 
145
  \usepackage{setspace}
146
-
147
  \usepackage{nicematrix}
148
  \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
149
  \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
 
138
  showtabs=false,
139
  tabsize=2
140
  }
141
+
142
  \lstset{style=mycodestyle}
143
 
144
 
145
  \usepackage{setspace}
146
+
147
  \usepackage{nicematrix}
148
  \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
149
  \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
app/scripts/latex-to-mdx/package-lock.json CHANGED
Binary files a/app/scripts/latex-to-mdx/package-lock.json and b/app/scripts/latex-to-mdx/package-lock.json differ
 
app/src/content/article.mdx CHANGED
The diff for this file is too large to render. See raw diff