Skip to content

Latest commit

 

History

History
82 lines (53 loc) · 2.48 KB

README.md

File metadata and controls

82 lines (53 loc) · 2.48 KB

A commonmark viewer for egui

Crate Documentation

showcase

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:

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);

Features

  • 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

Parsing backends

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"] }

Why two parsing backends?

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.

Differences in support

Currently both support the same feature set

Known rendering differences

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

License

Licensed under either of

at your option.