Skip to main content

Crate glamour

Crate glamour 

Source
Expand description

§Glamour

A markdown rendering library for terminal applications.

Glamour transforms markdown into beautifully styled terminal output with:

  • Styled headings, lists, and tables
  • Code block formatting with optional syntax highlighting
  • Link and image handling
  • Customizable themes (Dark, Light, ASCII, Pink)

§Role in charmed_rust

Glamour is the Markdown renderer for the ecosystem:

  • glow is the CLI reader built directly on glamour.
  • demo_showcase uses glamour for in-app documentation pages.
  • lipgloss provides the styling primitives that glamour applies.

§Example

use glamour::{render, Renderer, Style};

// Quick render with default dark style
let output = render("# Hello\n\nThis is **bold** text.", Style::Dark).unwrap();
println!("{}", output);

// Custom renderer with word wrap
let renderer = Renderer::new()
    .with_style(Style::Light)
    .with_word_wrap(80);
let output = renderer.render("# Heading\n\nParagraph text.");

§Feature Flags

  • syntax-highlighting: Enable syntax highlighting for code blocks using syntect. This adds ~2MB to binary size due to embedded syntax definitions for ~60 languages.

§Example with syntax highlighting

[dependencies]
glamour = { version = "0.1", features = ["syntax-highlighting"] }

When enabled, code blocks with language annotations (e.g., ```rust) will be rendered with syntax highlighting using the configured theme. See docs/SYNTAX_HIGHLIGHTING_RESEARCH.md for implementation details.

Modules§

prelude
Prelude module for convenient imports.
table
Table Rendering

Structs§

AnsiOptions
Options for the markdown renderer (Go API: AnsiOptions).
StyleBlock
Block-level style settings.
StyleCodeBlock
Code block style settings.
StyleConfig
Complete style configuration for rendering.
StyleList
List style settings.
StylePrimitive
Primitive style settings for text elements.
StyleTable
Table style settings.
StyleTask
Task item style settings.
TermRenderer
Markdown renderer for terminal output (Go API: TermRenderer).

Enums§

Style
Available built-in styles.

Functions§

ascii_style
Creates the ASCII style configuration.
available_styles
Available style names for configuration.
dark_style
Creates the dark style configuration.
dracula_style
Creates the Dracula style configuration.
light_style
Creates the light style configuration.
pink_style
Creates the pink style configuration.
render
Render markdown with the specified style.
render_with_environment_config
Render markdown with the default dark style.
tokyo_night_style
Creates the Tokyo Night style configuration.

Type Aliases§

Renderer
Backwards-compatible type alias for TermRenderer.
RendererOptions
Backwards-compatible type alias for AnsiOptions.