Spaces:
Sleeping
Sleeping
File size: 2,476 Bytes
df4fada 6981282 ee811be df4fada 6981282 df4fada 6981282 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ---
title: LaTeX Editor
emoji: π
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.12.0
app_file: app.py
pinned: false
license: mit
---
# LaTeX Editor
A real-time LaTeX editor with instant PDF preview, optimized for speed and concurrency.
## Features
- **Live Preview**: See your PDF update as you type (500ms debounce)
- **Syntax Highlighting**: Full LaTeX syntax highlighting with Dracula theme
- **Fast Compilation**: ProcessPoolExecutor for parallel compilations
- **Caching**: LRU cache skips recompilation for identical content
- **Resizable Panels**: Drag the divider to adjust editor/preview ratio
- **Zoom Controls**: Zoom in/out on the PDF preview
## Local Development
1. Install TeX Live:
```bash
# macOS
brew install --cask mactex
# Ubuntu/Debian
sudo apt-get install texlive-latex-base texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra
```
2. Install Python dependencies:
```bash
pip install -r requirements.txt
```
3. Run the server:
```bash
python app.py
```
4. Open http://localhost:7860
## Deployment on Hugging Face Spaces
The `packages.txt` file automatically installs TeX Live packages when deployed to HF Spaces.
## Architecture
```
βββββββββββββββββββ WebSocket ββββββββββββββββββββββββ
β Browser βββββββββββββββββββββΊβ FastAPI Server β
β - CodeMirror β β - WebSocket Handler β
β - PDF.js β β - ProcessPoolExec β
βββββββββββββββββββ β - LRU Cache β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β pdflatex β
β (parallel workers) β
ββββββββββββββββββββββββ
```
## Tech Stack
- **Backend**: FastAPI + uvicorn
- **Frontend**: Vanilla JS + CodeMirror 5 + PDF.js
- **Compilation**: pdflatex (TeX Live)
|