render_readme

Crates.iorender_readme
lib.rsrender_readme
version0.15.0
created_at2022-09-03 16:21:28.147166+00
updated_at2025-06-29 23:06:02.535581+00
descriptionRender Markdown or reStructuredText with syntax highlighting and image filtering similar to GitHub's
homepage
repositoryhttps://gitlab.com/lib.rs/render_readme
max_upload_size
id657953
size1,086,748
Kornel (kornelski)

documentation

README

Render README files the same way(ish) as GitHub et al.

Readme to HTML conversion for lib.rs.

Supports:

  • Markdown with GitHub's extensions (natively in Rust), reStructuredText (via rst2html), and a tiny subset of AsciiDoc.
  • URL rewriting.
  • Filtering out unsafe HTML.
  • GitHub Emoji.
  • GitHub's hack for light/dark images.
  • Supports syntax highlighting using Sublime Text syntax definitions. The markup is color agnostic. Instead of hardcoding colors, it writes scope class names. Actual theme colors are in the style subproject.
  • Fuzzy detection of programming languages used in <code> tags, tuned for languages mentioned by Rust crates.

Installation

Install docutils package, so that rst2html command is available (in PATH).

It needs to write a file to system's temp directory for rst2html. If you clear temp while the program is running, rst support may fail.

Making a theme

It generates HTML <span> class names based on scope names from Sublime Syntax files, but:

  • words used in the scopes are abbreviated. See highlight.rs for the list of abbreviations.
  • Only scopes with 2 and 3 levels are added (more specific scopes are truncated to the first 3 words).

Adding more languages

All languages are precompiled from syntaxes/ submodule.

tmLanguage definitions need to be converted first.

Commit count: 185

cargo fmt