A commonmark viewer for egui
While this crate's main focus is commonmark, it also supports a subset of Github's markdown syntax: tables, strikethrough, tasklists and footnotes.
In Cargo.toml:
egui_commonmark = "0.11"
# 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);
better_syntax_highlighting
: Syntax highlighting inside code blocks withsyntect
svg
: Support for viewing svg imagesfetch
: Images with urls will be downloaded and displayed
egui_commonmark offers experimental support for using comrak as parsing backend. By default pulldown_cmark is used. To use comrak instead do:
egui_commonmark = { version = "0.11", default-features = false, features = ["load-images", "comrak"] }
egui_commonmark was originally implemented using pulldown_cmark, however comrak has stricter commonmark/github style markdown support. In addition it allows the crate to support more features than pulldown_cmark can offer with regards to github style markdown.
pulldown_cmark has fewer dependencies and should theoretically be faster.
Due to these reasons both backends are supported. At least for now.
Currently both support the same feature set
Type | pulldown_cmark | comrak |
---|---|---|
Footers | Placed when they appear | Placed at the end |
Spec incompatibilies | Blocks such as images can be rendered inside tables. This is against the spec | Disallowed |
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.