26 releases (15 breaking)

new 0.16.1 May 12, 2024
0.15.0 Apr 2, 2024
0.14.0 Mar 26, 2024
0.10.2 Dec 13, 2023
0.1.3 Mar 24, 2022

#43 in GUI

Download history 1113/week @ 2024-01-22 1187/week @ 2024-01-29 1508/week @ 2024-02-05 1403/week @ 2024-02-12 1195/week @ 2024-02-19 1727/week @ 2024-02-26 1139/week @ 2024-03-04 1620/week @ 2024-03-11 2128/week @ 2024-03-18 1434/week @ 2024-03-25 1904/week @ 2024-04-01 3122/week @ 2024-04-08 3774/week @ 2024-04-15 3643/week @ 2024-04-22 3619/week @ 2024-04-29 2634/week @ 2024-05-06

13,748 downloads per month
Used in 18 crates (4 directly)

MIT/Apache

89KB
2K SLoC

A commonmark viewer for egui

Crate Documentation

showcase

While this crate's main focus is commonmark, it also supports a subset of Github's markdown syntax: tables, strikethrough, tasklists and footnotes.

Usage

In Cargo.toml:

egui_commonmark = "0.16"
# Specify what image formats you want to use
image = { version = "0.24", default-features = false, features = ["png"] }
use egui_commonmark::*;
let markdown =
r"# Hello world

* A list
* [ ] Checkbox
";

let mut cache = CommonMarkCache::default();
CommonMarkViewer::new("viewer").show(ui, &mut cache, markdown);

Compile time evaluation of markdown

If you want to embed markdown directly the binary then you can enable the macros feature. This will do the parsing of the markdown at compile time and output egui widgets.

Example

use egui_commonmark::{CommonMarkCache, commonmark};
let mut cache = CommonMarkCache::default();
let _response = commonmark!("example", ui, &mut cache, "# ATX Heading Level 1");

Alternatively you can embed a file

Example

use egui_commonmark::{CommonMarkCache, commonmark_str};
let mut cache = CommonMarkCache::default();
commonmark_str!("example_file", ui, &mut cache, "content.md");

Features

  • macros: macros for compile time parsing of markdown
  • better_syntax_highlighting: Syntax highlighting inside code blocks with syntect
  • svg: Support for viewing svg images
  • fetch: Images with urls will be downloaded and displayed

Examples

For an easy intro check out the hello_world example. To see all the different features egui_commonmark has to offer check out the book example.

License

Licensed under either of

at your option.

Dependencies

~5–20MB
~235K SLoC