ChrisRega/example-blog-client

Add Markdown View

Closed this issue · 1 comments

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());
            });
        });
   ....

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