pandoc_wasm 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.npmignore +41 -0
- data/RALPH_TASK.md +52 -0
- data/README.md +382 -0
- data/Rakefile +27 -0
- data/SECURITY.md +343 -0
- data/cabal.project +45 -0
- data/index.js +24 -0
- data/lib/download.js +201 -0
- data/lib/pandoc_wasm/downloader.rb +142 -0
- data/lib/pandoc_wasm/version.rb +5 -0
- data/lib/pandoc_wasm.rb +36 -0
- data/package.json +39 -0
- data/pandoc_wasm.gemspec +47 -0
- metadata +67 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5b94721e546d31230f7402b4cae87b29ec1829b38d492e79ec00e84fac357776
|
|
4
|
+
data.tar.gz: 8c7138acc5b8acc863a3c24575e6fe01e51206de9b72453145d9123c1501688d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e60162d62c4bd8eb7a1c05f1d585ab25d23de6fa18fa3eb1cf4a4527ac7ec333a050d4da94b18fda25544dc65672cfedce9ddc63943679bc16c87de1e1a4de1d
|
|
7
|
+
data.tar.gz: 1b17517567d26e823b228010754ecd47ceb63d4ece62f3f6d445254f808ed6c1509f9d1c58151c5e6e659009dce5533626efa624fcf0671085b80ee87e97e290
|
data/.npmignore
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Build outputs
|
|
2
|
+
dist-newstyle/
|
|
3
|
+
*.pptx
|
|
4
|
+
*.docx
|
|
5
|
+
|
|
6
|
+
# Haskell build artifacts
|
|
7
|
+
*.hi
|
|
8
|
+
*.o
|
|
9
|
+
*.dyn_hi
|
|
10
|
+
*.dyn_o
|
|
11
|
+
cabal.project.local
|
|
12
|
+
cabal.project.local~
|
|
13
|
+
|
|
14
|
+
# Source patches (not needed in npm package)
|
|
15
|
+
patches/
|
|
16
|
+
|
|
17
|
+
# Development files
|
|
18
|
+
.ralph/
|
|
19
|
+
.cursor/
|
|
20
|
+
.vscode/
|
|
21
|
+
*.swp
|
|
22
|
+
*~
|
|
23
|
+
|
|
24
|
+
# macOS
|
|
25
|
+
.DS_Store
|
|
26
|
+
|
|
27
|
+
# Git
|
|
28
|
+
.git/
|
|
29
|
+
.gitignore
|
|
30
|
+
|
|
31
|
+
# Documentation (keep README.md)
|
|
32
|
+
SECURITY.md
|
|
33
|
+
RALPH_TASK.md
|
|
34
|
+
|
|
35
|
+
# Cabal project file
|
|
36
|
+
cabal.project
|
|
37
|
+
|
|
38
|
+
# Test files
|
|
39
|
+
tests/
|
|
40
|
+
*.md
|
|
41
|
+
!README.md
|
data/RALPH_TASK.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Pandoc WASM Compilation
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
Compile Pandoc to WebAssembly for converting Markdown to PPTX (and other formats).
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- ghc-wasm-meta: Fully installed at ~/.ghc-wasm/
|
|
8
|
+
- wasmtime: Available at ~/.ghc-wasm/wasmtime/bin/wasmtime (v41.0.0)
|
|
9
|
+
- Target: Pandoc 3.8.3 (latest stable on Hackage)
|
|
10
|
+
- **STATUS: COMPLETE - pandoc.wasm works!**
|
|
11
|
+
|
|
12
|
+
## Criteria
|
|
13
|
+
|
|
14
|
+
### Phase 0: Complete ghc-wasm-meta Installation
|
|
15
|
+
- [x] Run bootstrap.sh to install GHC WASM compiler
|
|
16
|
+
- [x] Verify wasm32-wasi-ghc --version works (9.12.3.20251231)
|
|
17
|
+
|
|
18
|
+
### Phase 1: Project Setup and Build
|
|
19
|
+
- [x] Create cabal.project with WASM-compatible configuration
|
|
20
|
+
- [x] Run wasm32-wasi-cabal update
|
|
21
|
+
- [x] Build pandoc-cli with wasm32-wasi-cabal
|
|
22
|
+
|
|
23
|
+
### Phase 2: Handle Dependency Failures (if needed)
|
|
24
|
+
- [x] Address basement WASM/GHC 9.12 compatibility (patched)
|
|
25
|
+
- [x] Address digest zlib dependency (disabled pkg-config)
|
|
26
|
+
- [x] Address crypton argon2 pthread issue (added ARGON2_NO_THREADS)
|
|
27
|
+
- [x] Address xml-conduit Custom build type issue (patched to Simple)
|
|
28
|
+
- [x] Address pandoc-cli threaded RTS issue (removed -threaded flag)
|
|
29
|
+
- [x] Address network socket stubs for WASI (added socket function stubs)
|
|
30
|
+
|
|
31
|
+
### Phase 3: Validation
|
|
32
|
+
- [x] Create test markdown files (small.md, medium.md, large.md)
|
|
33
|
+
- [x] pandoc.wasm binary exists (166MB)
|
|
34
|
+
- [x] Successfully convert small.md to PPTX
|
|
35
|
+
- [x] Successfully convert medium.md to PPTX
|
|
36
|
+
- [x] Successfully convert large.md to PPTX
|
|
37
|
+
- [x] Output PPTX files are valid
|
|
38
|
+
|
|
39
|
+
## Test Command
|
|
40
|
+
```bash
|
|
41
|
+
# Verify WASM compilation produces working output
|
|
42
|
+
source ~/.ghc-wasm/env && wasmtime run --dir . pandoc.wasm -o test.pptx small.md
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes
|
|
46
|
+
- Use flags: `-lua -server` to disable problematic features
|
|
47
|
+
- Use `+embed_data_files` to include templates in binary
|
|
48
|
+
- wasmtime needs `--dir .` to access host filesystem
|
|
49
|
+
- No external processes or network in WASI
|
|
50
|
+
- Packages with `build-type: Custom` need to be patched to Simple
|
|
51
|
+
- The `-threaded` flag must be removed from executable ghc-options
|
|
52
|
+
- Socket functions are stubbed (return ENOSYS) - network features won't work
|
data/README.md
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Pandoc WASM
|
|
2
|
+
|
|
3
|
+
> Pandoc 3.8.3 compilé en WebAssembly pour la conversion de documents dans des environnements WASI.
|
|
4
|
+
|
|
5
|
+
[](https://pandoc.org/)
|
|
6
|
+
[](https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta)
|
|
7
|
+
[](#disclaimer)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Disclaimer / Avertissement
|
|
12
|
+
|
|
13
|
+
> **Ce projet est expérimental et constitue avant tout un travail de recherche.**
|
|
14
|
+
|
|
15
|
+
- Les patches appliqués aux dépendances Haskell peuvent ne pas être parfaits et n'ont pas été audités de manière exhaustive
|
|
16
|
+
- Ce projet peut ne pas convenir à tous les cas d'usage
|
|
17
|
+
- Les fichiers de travail de **Ralph** (agent IA) ont été volontairement conservés dans le dossier `.ralph/` pour montrer la méthodologie et le processus de développement
|
|
18
|
+
- Le binaire résultant (166 MB) est optimisé pour la compatibilité WASI, pas pour la taille
|
|
19
|
+
|
|
20
|
+
**Utilisez ce projet en connaissance de cause et à vos propres risques.**
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Introduction
|
|
25
|
+
|
|
26
|
+
Ce projet permet de compiler [Pandoc](https://pandoc.org/), le convertisseur de documents universel, en WebAssembly (WASM) pour l'exécuter dans des environnements compatibles WASI (WebAssembly System Interface).
|
|
27
|
+
|
|
28
|
+
### Résultat
|
|
29
|
+
|
|
30
|
+
- **Binaire** : `pandoc.wasm` (~166 MB)
|
|
31
|
+
- **Runtime** : [wasmtime](https://wasmtime.dev/) ou tout runtime WASI compatible
|
|
32
|
+
- **Fonctionnalités** : Conversion Markdown vers HTML, PPTX, DOCX, et autres formats supportés par Pandoc
|
|
33
|
+
- **Limitations** : Pas de réseau, pas de Lua, pas de serveur HTTP (voir [Limitations](#limitations))
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation via npm
|
|
38
|
+
|
|
39
|
+
Pour utiliser `pandoc.wasm` comme dépendance dans vos projets Node.js :
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @nathanhimpens/pandoc-wasm
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Le fichier `pandoc.wasm` sera automatiquement téléchargé depuis les [GitHub Releases](https://github.com/NathanHimpens/pandoc-wasm/releases) lors de l'installation.
|
|
46
|
+
|
|
47
|
+
### Utilisation dans votre code
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const pandocWasmPath = require('@nathanhimpens/pandoc-wasm');
|
|
51
|
+
const { execSync } = require('child_process');
|
|
52
|
+
|
|
53
|
+
// Utilisation avec wasmtime
|
|
54
|
+
execSync(`wasmtime run --dir . ${pandocWasmPath} -o output.pptx input.md`);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Note importante
|
|
58
|
+
|
|
59
|
+
Le package nécessite que `pandoc.wasm` soit disponible dans une release GitHub. Si aucune release n'existe encore, vous devrez :
|
|
60
|
+
|
|
61
|
+
1. Compiler le binaire vous-même (voir section [HOW TO : Compiler soi-même](#how-to--compiler-soi-même))
|
|
62
|
+
2. Créer une release GitHub avec `pandoc.wasm` en pièce jointe
|
|
63
|
+
3. Ou copier manuellement le fichier dans `node_modules/@nathanhimpens/pandoc-wasm/`
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Installation via RubyGems
|
|
68
|
+
|
|
69
|
+
Pour utiliser `pandoc.wasm` comme dépendance dans vos projets Ruby/Rails :
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
gem install pandoc_wasm
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Ou ajoutez-le à votre `Gemfile` :
|
|
76
|
+
|
|
77
|
+
```ruby
|
|
78
|
+
gem 'pandoc_wasm', '~> 1.0'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Le fichier `pandoc.wasm` sera automatiquement téléchargé depuis les [GitHub Releases](https://github.com/NathanHimpens/pandoc-wasm/releases) lors de la première utilisation (lazy loading).
|
|
82
|
+
|
|
83
|
+
### Utilisation dans votre code Ruby
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
require 'pandoc_wasm'
|
|
87
|
+
|
|
88
|
+
# Obtenir le chemin vers pandoc.wasm
|
|
89
|
+
pandoc_path = PandocWasm.path
|
|
90
|
+
# => "/path/to/gems/pandoc_wasm-1.0.0/lib/pandoc_wasm/pandoc.wasm"
|
|
91
|
+
|
|
92
|
+
# Utilisation avec wasmtime
|
|
93
|
+
system("wasmtime run --dir . #{pandoc_path} -o output.pptx input.md")
|
|
94
|
+
|
|
95
|
+
# Vérifier si pandoc.wasm est disponible
|
|
96
|
+
if PandocWasm.available?
|
|
97
|
+
# Utiliser pandoc.wasm
|
|
98
|
+
end
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Note importante
|
|
102
|
+
|
|
103
|
+
La gem nécessite que `pandoc.wasm` soit disponible dans une release GitHub. Si aucune release n'existe encore, vous devrez :
|
|
104
|
+
|
|
105
|
+
1. Compiler le binaire vous-même (voir section [HOW TO : Compiler soi-même](#how-to--compiler-soi-même))
|
|
106
|
+
2. Créer une release GitHub avec `pandoc.wasm` en pièce jointe
|
|
107
|
+
3. Ou copier manuellement le fichier dans le répertoire de la gem installée
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Comment ça fonctionne
|
|
112
|
+
|
|
113
|
+
```mermaid
|
|
114
|
+
flowchart LR
|
|
115
|
+
A[Source Haskell] --> B[GHC WASM 9.12]
|
|
116
|
+
B --> C[pandoc.wasm]
|
|
117
|
+
C --> D[wasmtime]
|
|
118
|
+
D --> E[Conversion de documents]
|
|
119
|
+
|
|
120
|
+
subgraph patches [Packages Patchés]
|
|
121
|
+
P1[basement]
|
|
122
|
+
P2[memory]
|
|
123
|
+
P3[network]
|
|
124
|
+
P4[crypton]
|
|
125
|
+
P5[cborg]
|
|
126
|
+
P6[xml-conduit]
|
|
127
|
+
P7[pandoc-cli]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
patches --> B
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Le compilateur GHC WASM cross-compile le code Haskell vers WebAssembly. Plusieurs packages ont dû être patchés pour supporter la plateforme 32-bit WASM et l'environnement WASI limité.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## HOW TO : Compiler soi-même
|
|
138
|
+
|
|
139
|
+
### Prérequis
|
|
140
|
+
|
|
141
|
+
| Outil | Version | Description |
|
|
142
|
+
|-------|---------|-------------|
|
|
143
|
+
| [ghc-wasm-meta](https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta) | 9.12 | Compilateur GHC pour WASM |
|
|
144
|
+
| [wasmtime](https://wasmtime.dev/) | >= 41.0 | Runtime WASI pour exécuter le binaire |
|
|
145
|
+
| [cabal](https://www.haskell.org/cabal/) | >= 3.10 | Gestionnaire de packages Haskell (inclus dans ghc-wasm-meta) |
|
|
146
|
+
|
|
147
|
+
### Étape 1 : Installer ghc-wasm-meta
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Installation du compilateur GHC WASM
|
|
151
|
+
cd ~
|
|
152
|
+
curl -sSL https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/bootstrap.sh | FLAVOUR=9.12 sh
|
|
153
|
+
|
|
154
|
+
# Charger l'environnement (à ajouter dans ~/.zshrc ou ~/.bashrc)
|
|
155
|
+
source ~/.ghc-wasm/env
|
|
156
|
+
|
|
157
|
+
# Vérifier l'installation
|
|
158
|
+
wasm32-wasi-ghc --version
|
|
159
|
+
# Devrait afficher: The Glorious Glasgow Haskell Compilation System, version 9.12.x
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Étape 2 : Cloner ce repository
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
git clone https://github.com/SleePy-nh/pandoc-wasm.git
|
|
166
|
+
cd pandoc-wasm
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Étape 3 : Mettre à jour l'index des packages
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
source ~/.ghc-wasm/env
|
|
173
|
+
wasm32-wasi-cabal update
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Étape 4 : Compiler Pandoc
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Compilation (peut prendre 30-60 minutes selon votre machine)
|
|
180
|
+
# L'option -j1 évite les race conditions de compilation
|
|
181
|
+
wasm32-wasi-cabal build pandoc-cli -j1
|
|
182
|
+
|
|
183
|
+
# Le binaire se trouve dans :
|
|
184
|
+
# dist-newstyle/build/wasm32-wasi/ghc-9.12.x/pandoc-cli-3.8.3/x/pandoc/build/pandoc/pandoc.wasm
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Étape 5 : Copier le binaire
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
cp dist-newstyle/build/wasm32-wasi/ghc-*/pandoc-cli-3.8.3/x/pandoc/build/pandoc/pandoc.wasm .
|
|
191
|
+
ls -lh pandoc.wasm
|
|
192
|
+
# Devrait afficher ~166M
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Étape 6 : Tester
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Test simple : Markdown vers HTML
|
|
199
|
+
echo "# Hello World" | wasmtime run --dir . pandoc.wasm
|
|
200
|
+
|
|
201
|
+
# Test : Markdown vers PowerPoint
|
|
202
|
+
wasmtime run --dir . pandoc.wasm -o output.pptx tests/small.md
|
|
203
|
+
ls -la output.pptx
|
|
204
|
+
|
|
205
|
+
# Tests de validation complets
|
|
206
|
+
wasmtime run --dir . pandoc.wasm -o small.pptx tests/small.md
|
|
207
|
+
wasmtime run --dir . pandoc.wasm -o medium.pptx tests/medium.md
|
|
208
|
+
wasmtime run --dir . pandoc.wasm -o large.pptx tests/large.md
|
|
209
|
+
echo "Tests réussis si les 3 fichiers .pptx sont créés"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Utilisation
|
|
215
|
+
|
|
216
|
+
### Syntaxe de base
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
wasmtime run --dir . pandoc.wasm [OPTIONS] [FICHIER_ENTREE]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
> **Important** : L'option `--dir .` est obligatoire pour donner accès au système de fichiers via WASI.
|
|
223
|
+
|
|
224
|
+
### Exemples
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Markdown vers HTML (sortie standard)
|
|
228
|
+
wasmtime run --dir . pandoc.wasm document.md
|
|
229
|
+
|
|
230
|
+
# Markdown vers PowerPoint
|
|
231
|
+
wasmtime run --dir . pandoc.wasm -o presentation.pptx document.md
|
|
232
|
+
|
|
233
|
+
# Markdown vers DOCX
|
|
234
|
+
wasmtime run --dir . pandoc.wasm -o document.docx input.md
|
|
235
|
+
|
|
236
|
+
# Spécifier les formats explicitement
|
|
237
|
+
wasmtime run --dir . pandoc.wasm -f markdown -t html document.md
|
|
238
|
+
|
|
239
|
+
# Depuis stdin
|
|
240
|
+
echo "# Titre" | wasmtime run --dir . pandoc.wasm -t html
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Formats supportés
|
|
244
|
+
|
|
245
|
+
Les formats de Pandoc sont supportés, à l'exception de ceux nécessitant :
|
|
246
|
+
- Des appels réseau (HTTP)
|
|
247
|
+
- Le moteur Lua
|
|
248
|
+
- Des processus externes (LaTeX pour PDF)
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Collaboration avec Ralph
|
|
253
|
+
|
|
254
|
+
Ce projet a été réalisé avec l'aide de **Ralph**, un agent IA autonome spécialisé dans les tâches de développement complexes. Ralph a travaillé sur ce projet en **4 sessions**, documentées dans le dossier `.ralph/`.
|
|
255
|
+
|
|
256
|
+
### Fichiers de travail conservés
|
|
257
|
+
|
|
258
|
+
| Fichier | Description |
|
|
259
|
+
|---------|-------------|
|
|
260
|
+
| `.ralph/progress.md` | Journal de progression détaillé |
|
|
261
|
+
| `.ralph/signs.md` | Leçons apprises et pièges à éviter |
|
|
262
|
+
| `.ralph/activity.log` | Log des commandes exécutées |
|
|
263
|
+
| `.ralph/tasks.yaml` | État des tâches |
|
|
264
|
+
| `RALPH_TASK.md` | Définition initiale de la tâche |
|
|
265
|
+
|
|
266
|
+
### Pourquoi conserver ces fichiers ?
|
|
267
|
+
|
|
268
|
+
Ces fichiers montrent :
|
|
269
|
+
1. **La méthodologie** : Comment aborder la compilation WASM de projets Haskell complexes
|
|
270
|
+
2. **Les obstacles rencontrés** : Problèmes de compatibilité 32-bit, APIs manquantes, etc.
|
|
271
|
+
3. **Les solutions appliquées** : Patches spécifiques pour chaque package
|
|
272
|
+
4. **La transparence** : Le processus complet de développement est visible
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Packages Patchés
|
|
277
|
+
|
|
278
|
+
Sept packages ont nécessité des modifications pour compiler en WASM. Voir [SECURITY.md](SECURITY.md) pour les détails techniques et implications de sécurité.
|
|
279
|
+
|
|
280
|
+
| Package | Version | Raison du patch |
|
|
281
|
+
|---------|---------|-----------------|
|
|
282
|
+
| `basement` | 0.0.16 | Compatibilité 32-bit, suppression GHC.IntWord64 |
|
|
283
|
+
| `memory` | 0.18.0 | Désactivation mmap, corrections FFI |
|
|
284
|
+
| `network` | 3.2.8.0 | Stubs pour fonctions socket non supportées par WASI |
|
|
285
|
+
| `cborg` | 0.2.10.0 | Corrections primitives 32-bit |
|
|
286
|
+
| `crypton` | 1.0.5 | Désactivation pthread (ARGON2_NO_THREADS) |
|
|
287
|
+
| `xml-conduit` | 1.10.1.0 | Build-type Custom → Simple |
|
|
288
|
+
| `pandoc-cli` | 3.8.3 | Suppression flag -threaded |
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Limitations
|
|
293
|
+
|
|
294
|
+
### Fonctionnalités désactivées
|
|
295
|
+
|
|
296
|
+
| Fonctionnalité | Raison | Alternative |
|
|
297
|
+
|----------------|--------|-------------|
|
|
298
|
+
| **Lua scripting** | Complexité d'intégration WASM | Utiliser des filtres JSON |
|
|
299
|
+
| **Serveur HTTP** | Pas de réseau en WASI | N/A |
|
|
300
|
+
| **Requêtes réseau** | WASI ne supporte pas les sockets | Télécharger les ressources localement |
|
|
301
|
+
| **PDF via LaTeX** | Nécessite processus externe | Utiliser HTML ou DOCX |
|
|
302
|
+
|
|
303
|
+
### Contraintes techniques
|
|
304
|
+
|
|
305
|
+
- **Mono-thread** : Le runtime WASM n'a pas de threading
|
|
306
|
+
- **Pas de mmap** : Memory-mapping désactivé
|
|
307
|
+
- **Fonctions réseau stubées** : Retournent `ENOSYS`
|
|
308
|
+
- **Taille du binaire** : ~166 MB (données embarquées)
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Leçons apprises
|
|
313
|
+
|
|
314
|
+
Extraits de `.ralph/signs.md` - les pièges à éviter lors de la compilation WASM :
|
|
315
|
+
|
|
316
|
+
### GHC.IntWord64 supprimé dans GHC 9.4+
|
|
317
|
+
|
|
318
|
+
> Les primitives `Int64#`/`Word64#` sont maintenant dans `GHC.Prim`, pas `GHC.IntWord64`.
|
|
319
|
+
|
|
320
|
+
### Packages avec Custom Setup.hs
|
|
321
|
+
|
|
322
|
+
> Les packages avec `build-type: Custom` échouent car le Setup.hs est compilé pour le HOST, pas la TARGET WASM. Solution : patcher vers `build-type: Simple`.
|
|
323
|
+
|
|
324
|
+
### Flag -threaded incompatible
|
|
325
|
+
|
|
326
|
+
> GHC WASM n'a pas de runtime threadé. Retirer `-threaded` des ghc-options.
|
|
327
|
+
|
|
328
|
+
### Stubs réseau WASI
|
|
329
|
+
|
|
330
|
+
> WASI P1 fournit certaines fonctions socket (accept, send, recv) mais pas d'autres (socket, bind, listen, connect). Ne stubber que les fonctions manquantes.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Structure du projet
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
pandoc-wasm/
|
|
338
|
+
├── README.md # Ce fichier
|
|
339
|
+
├── SECURITY.md # Détails des patches de sécurité
|
|
340
|
+
├── RALPH_TASK.md # Définition de la tâche pour Ralph
|
|
341
|
+
├── cabal.project # Configuration de build Cabal
|
|
342
|
+
├── .gitignore
|
|
343
|
+
├── tests/ # Fichiers de test Markdown
|
|
344
|
+
│ ├── small.md
|
|
345
|
+
│ ├── medium.md
|
|
346
|
+
│ ├── large.md
|
|
347
|
+
│ └── test.md
|
|
348
|
+
├── patches/ # Packages Haskell patchés
|
|
349
|
+
│ ├── basement-0.0.16/
|
|
350
|
+
│ ├── memory-0.18.0/
|
|
351
|
+
│ ├── network-3.2.8.0/
|
|
352
|
+
│ ├── cborg-0.2.10.0/
|
|
353
|
+
│ ├── crypton-1.0.5/
|
|
354
|
+
│ ├── xml-conduit-1.10.1.0/
|
|
355
|
+
│ └── pandoc-cli-3.8.3/
|
|
356
|
+
└── .ralph/ # Fichiers de travail Ralph
|
|
357
|
+
├── progress.md
|
|
358
|
+
├── signs.md
|
|
359
|
+
├── activity.log
|
|
360
|
+
└── tasks.yaml
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Licence
|
|
366
|
+
|
|
367
|
+
Ce projet utilise Pandoc qui est sous licence GPL-2.0-or-later. Les patches sont fournis sous la même licence que les packages originaux.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Acknowledgment
|
|
372
|
+
|
|
373
|
+
Ce projet s'inspire du travail de [haskell-wasm/pandoc-wasm](https://github.com/haskell-wasm/pandoc-wasm), qui a démontré la faisabilité de compiler Pandoc en WebAssembly.
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Ressources
|
|
378
|
+
|
|
379
|
+
- [Pandoc Documentation](https://pandoc.org/MANUAL.html)
|
|
380
|
+
- [GHC WASM Meta](https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta)
|
|
381
|
+
- [WASI Specification](https://wasi.dev/)
|
|
382
|
+
- [Wasmtime](https://wasmtime.dev/)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
task default: :test
|
|
7
|
+
|
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
|
9
|
+
t.libs << 'test'
|
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
|
11
|
+
t.verbose = true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'Build the gem'
|
|
15
|
+
task :build do
|
|
16
|
+
system 'gem build pandoc_wasm.gemspec'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc 'Install the gem locally'
|
|
20
|
+
task :install => :build do
|
|
21
|
+
system 'gem install ./pandoc_wasm-*.gem'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Publish the gem to RubyGems'
|
|
25
|
+
task :release => :build do
|
|
26
|
+
system 'gem push pandoc_wasm-*.gem'
|
|
27
|
+
end
|