28 releases (17 breaking)

0.18.0 Sep 26, 2024
0.17.0 Jul 3, 2024
0.16.1 May 12, 2024
0.14.0 Mar 26, 2024
0.1.3 Mar 24, 2022

#37 in GUI

Download history 5261/week @ 2024-07-14 3582/week @ 2024-07-21 3375/week @ 2024-07-28 4051/week @ 2024-08-04 5474/week @ 2024-08-11 3431/week @ 2024-08-18 4458/week @ 2024-08-25 2699/week @ 2024-09-01 3611/week @ 2024-09-08 2215/week @ 2024-09-15 3063/week @ 2024-09-22 4172/week @ 2024-09-29 5551/week @ 2024-10-06 5548/week @ 2024-10-13 3507/week @ 2024-10-20 4127/week @ 2024-10-27

18,825 downloads per month
Used in 28 crates (7 directly)

MIT/Apache

84KB
1.5K 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.18"
# Specify what image formats you want to use
image = { version = "0.25", default-features = false, features = ["png"] }
use egui_commonmark::*;
let markdown =
r"# Hello world

* A list
* [ ] Checkbox
";

let mut cache = CommonMarkCache::default();
CommonMarkViewer::new().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!(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!(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–16MB
~221K SLoC