Crates.io | egui_commonmark |
lib.rs | egui_commonmark |
version | 0.18.0 |
source | src |
created_at | 2022-02-09 11:18:29.858351 |
updated_at | 2024-09-26 16:31:26.050126 |
description | Commonmark viewer for egui |
homepage | |
repository | https://github.com/lampsitter/egui_commonmark |
max_upload_size | |
id | 529632 |
size | 130,341 |
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.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);
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.
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
use egui_commonmark::{CommonMarkCache, commonmark_str};
let mut cache = CommonMarkCache::default();
commonmark_str!(ui, &mut cache, "content.md");
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
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.
Licensed under either of
at your option.