Skip to content

triblespace/gorbie_commonmark

 
 

Repository files navigation

A commonmark viewer for egui

Crate Documentation

showcase

This is a fork of egui_commonmark to customize the appearance so it better matches the GORBIE visual style.

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:

gorbie-commonmark = "0.22.1"
# Specify what image formats you want to use
image = { version = "0.25", default-features = false, features = ["png"] }
use gorbie_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 gorbie_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 gorbie_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
  • embedded_image: Load base64 image data urls from within markdown files

Examples

For an easy intro check out the hello_world example. To see all the different features gorbie_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:

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

at your option.

About

markdown viewer for GORBIE

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%