ChrisRega / example-blog-client

MIT License
6 stars 1 forks source link

Add Markdown View #3

Closed trapalleiro-git closed 1 year ago

trapalleiro-git commented 1 year ago

Add markdown view with https://github.com/lampsitter/egui_commonmark

   ....
   ui.heading(post.title.as_str());
    let tags = resolve_tags(post.tags.as_slice(), tags);
    ui.label(format!("Tagged: {}", tags.join(", ")));
    ui.label(format!("Date: {}", timestamp_to_string(post.timestamp)));

    ScrollArea::vertical()
        .auto_shrink([false; 2])
        .show_viewport(ui, |ui, _| {
            // ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
            //     ui.add(Label::new(post.post.as_str()).wrap(true))
            // });

            let mut cache = egui_commonmark::CommonMarkCache::default();

            egui::ScrollArea::vertical().show(ui, |ui| {
                CommonMarkViewer::new("viewer")
                    .max_image_width(Some(512))
                    .show(ui, &mut cache, post.post.as_str());
            });
        });
   ....
ChrisRega commented 1 year ago

@trapalleiro-git thanks for the heads-up about this crate. I just added it :)