-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3329565
commit e681407
Showing
6 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//! Make sure to run this example from the repo directory and not the example | ||
//! directory. To see all the features in full effect, run this example with | ||
//! `cargo r --example basic --all-features` | ||
use eframe::{egui, epi}; | ||
use egui_commonmark::*; | ||
|
||
struct App { | ||
cache: CommonMarkCache, | ||
} | ||
|
||
impl epi::App for App { | ||
fn name(&self) -> &str { | ||
"Markdown viewer" | ||
} | ||
|
||
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) { | ||
let text = r#"# Commonmark Viewer example | ||
A *little* ~~paragraph~~ __with__ `multiple` styles. | ||
| __A table!__ | | ||
| -------- | | ||
|  | | ||
| Some filler text | | ||
| [Link to repo](https://github.com/lampsitter/egui_commonmark) | | ||
```rs | ||
let mut vec = Vec::new(); | ||
vec.push(5); | ||
``` | ||
> Some smart quote here | ||
- [ ] A feature[^1] | ||
- [X] A completed feature | ||
1. Sub item | ||
[^1]: A footnote | ||
"#; | ||
|
||
egui::CentralPanel::default().show(ctx, |ui| { | ||
egui::ScrollArea::vertical().show(ui, |ui| { | ||
CommonMarkViewer::new("viewer") | ||
.max_image_width(Some(512)) | ||
.show(ui, &mut self.cache, text); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
fn main() { | ||
let options = eframe::NativeOptions::default(); | ||
eframe::run_native( | ||
Box::new(App { | ||
cache: CommonMarkCache::default(), | ||
}), | ||
options, | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Logo from https://github.com/rust-lang/rust-artwork |