writer / README.md
abidlabs's picture
abidlabs HF Staff
changes
ee811be

A newer version of the Gradio SDK is available: 6.12.0

Upgrade
metadata
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:

    # 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:

    pip install -r requirements.txt
    
  3. Run the server:

    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)