limn-pulldown-cmark 0.6.0

Stream-highlight fenced code blocks in pulldown-cmark Markdown events with limn
Documentation

limn-pulldown-cmark

pulldown-cmark event adapter for limn-hl. Replaces fenced code blocks with highlighted HTML while passing all other events through unchanged.

Install

cargo add limn-pulldown-cmark

Usage

use limn_pulldown_cmark::Highlighter;
use limn_pulldown_cmark::limn::{lang, render::HtmlOptions, theme};

let hl = Highlighter::new(
    lang::all(),
    HtmlOptions {
        theme: Some(&theme::TOKYO_NIGHT),
        line_numbers: true,
        ..Default::default()
    },
)
.with_auto_detect(true);

let html = hl.render_html("```rs\nfn main() {}\n```\n");

To use custom pulldown_cmark::Parser flags or inspect events, wrap any Event iterator with hl.events(parser). See docs/integrations.md for more details.