Expand description
A commonmark viewer for egui
§Example
let markdown =
r"# Hello world
* A list
* [ ] Checkbox
";
let mut cache = CommonMarkCache::default();
CommonMarkViewer::new().show(ui, &mut cache, markdown);
Remember to opt into the image formats you want to use!
image = { version = "0.25", default-features = false, features = ["png"] }§FAQ
§URL is not displayed when hovering over a link
By default egui does not show urls when you hover hyperlinks. To enable it, you can do the following before calling any ui related functions:
ui.style_mut().url_in_tooltip = true;§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");For more information check out the documentation for egui_commonmark_macros
§Features
-
macros— Enable proc macros for compile time generation of egui widgets from markdown -
nightly— Builds upon themacrosfeature. Enables tracking of markdown files to recompile when their content changes. Uses nightly features -
pulldown_cmark(enabled by default) — No-op feature -
better_syntax_highlighting— Syntax highlighting for code blocks using syntect -
load-images(enabled by default) — Enable loading of images. Make sure to also opt in to what image format you need through the image crate. -
svg— Support loading svg images -
fetch— Images with urls will be downloaded and displayed -
embedded_image— Allows loading base64 image data urls from within markdown files. e.g:data:image/png;base64,...Note that this is really space inefficient. No size limit is in place for the maximum allowed data in the url.This enables the data urls for your entire app as it installs an egui bytes loader in the background.
Currently this does not support wasm.
Macros§
Structs§
- Alert
- Alert
Bundle - Common
Mark Cache - A cache used for storing content such as images.
- Common
Mark Viewer
Type Aliases§
- Render
Html Fn - Takes
egui::Uiand the html text to be rendered/used - Render
Math Fn - Takes
egui::Ui, the math text to be rendered and whether it is inline