Satori Syntax Highlighter for Val Town

A syntax highlighter that generates images from code snippets. This is a port of the Satori Syntax Highlighter project to Val Town, restructured using Hono.

Features

  • Generate syntax-highlighted images from code snippets
  • Customize background color, language, and font size
  • Supports JavaScript, TypeScript, CSS, and HTML
  • Modular architecture with Hono

Project Structure

├── backend/
│   ├── index.ts                 # Main entry point with Hono setup
│   └── routes/
│       └── highlighter-route.ts # Highlighter API route
├── frontend/
│   ├── components/
│   │   └── Playground.tsx       # React component for the playground
│   ├── index.html               # HTML template
│   └── index.tsx                # Client-side entry point
└── shared/
    ├── types.ts                 # Shared TypeScript types
    └── utils.ts                 # Shared utilities

Technologies Used

  • Hono - Lightweight web framework
  • Satori - For rendering React components to SVG
  • Lowlight - For syntax highlighting
  • Yoga - For layout
  • React - For UI components

Usage

Visit the frontend page to customize and generate syntax-highlighted images. The API endpoint is available at /api/highlighter with the following parameters:

  • code: The code to highlight
  • background: The background color (default: gold)
  • lang: The language (js, css, typescript, xml)
  • fontSize: The font size (default: 16)

License

The MIT License (MIT).