https://github.com/lampsitter/egui_commonmark
Markdown viewer for egui
https://github.com/lampsitter/egui_commonmark
commonmark egui markdown rust
Last synced: 2 months ago
JSON representation
Markdown viewer for egui
- Host: GitHub
- URL: https://github.com/lampsitter/egui_commonmark
- Owner: lampsitter
- License: apache-2.0
- Created: 2022-02-09T10:40:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-12T16:53:44.000Z (3 months ago)
- Last Synced: 2025-03-12T17:39:23.165Z (3 months ago)
- Topics: commonmark, egui, markdown, rust
- Language: Rust
- Homepage:
- Size: 729 KB
- Stars: 110
- Watchers: 1
- Forks: 20
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-egui - egui_commonmark
README
# A commonmark viewer for [egui](https://github.com/emilk/egui)
[](https://crates.io/crates/egui_commonmark)
[](https://docs.rs/egui_commonmark)
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:
```toml
egui_commonmark = "0.20"
# Specify what image formats you want to use
image = { version = "0.25", default-features = false, features = ["png"] }
``````rust
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
```rust
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
```rust
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`](https://crates.io/crates/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.## 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:```rust
ui.style_mut().url_in_tooltip = true;
```## MSRV Policy
This crate uses the same MSRV as the latest released egui version.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.