GithubHelp home page GithubHelp logo

egui_commonmark's People

Contributors

abey79 avatar chrisp60 avatar crumblingstatue avatar elhamaryanpur avatar emilk avatar jprochazk avatar lampsitter avatar lazytanuki avatar localcc avatar zeozeozeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

egui_commonmark's Issues

Make types implement Debug

Currently, public structs from this crate don't implement Debug trait, which causes issues if I want to store cache in some object that is Debug, as well as goes against a pretty strong suggestion in Rust docs

Consider switching to the syntax highlighting library in `egui_extras`

I recently moved the syntax highlighting code I had in egui_demo_lib to egui_extras: emilk/egui#3333

Importantly, it has a simple fallback that works even without the syntect crate (which has a tendency to bloat .wasm files quite a bit).

egui_extras::syntax_highlighing does not yet support everything that egui_commonmark offers, in particular it doesn't yet have add_syntax_from_folder, add_syntax_from_str, add_syntax_themes_from_folder, and add_syntax_theme_from_bytes.

Add a "copy content" button to code blocks

Having a "copy content" button appearing on hover over code blocks (typically top right) is quite common on modern web template (e.g. in our own docs at Rerun). It would be great to have something similar in egui_commonmark.

image

This is currently covered by having the code block text selectable, but this feels a bit clunky. (It's nice to have though, in cases the user wants to copy only part of the text.)

image

Related to:

Copyable text

Is there a way to make part of a text (or a full markdown text) selectable and copyable?

Copy button doesn't work on Safari

Safari has a marked tendency of rejecting copy operations that it can't link to user action. For this reason, most copy operations used to fail on Safari with egui/wasm. This was recently fixed in egui 0.24 (emilk/egui#3513), and now copying from code blocks works when selecting text and copy. However it still fails when using the copy button.

Here is a dev build of Rerun based on egui 0.24 where select-and-copy works on Safari, but not the copy button:

https://demo.rerun.io/pr/4111/examples/structure_from_motion/

One must scroll down the description view to reach a code block:

image

Clicking the "Copy" button fails with this error:

image

For reference, this is another dev build that is based on egui 0.23 and where all forms of copying fail:

https://demo.rerun.io/pr/4324/examples/structure_from_motion/

Compile time parsing

It would be useful to skip the parsing for markdown embedded directly into the application.

Feature request: Support for mutable checkboxes

egui_commonmark supports rendering checkboxes, but they are not clickable.

Possible implementations:

  • There could be a version of CommonMarkViewer::show that takes &mut String, and mutates the string directly when a checkbox is clicked.
  • There could be some kind of a response from CommonMarkViewer::show that gives the byte position of the checkbox that was clicked, so the user could use it to update the string manually.

Place footnotes at the end

Requires collecting the events and process them when everything else has been parsed. Some ruler separation between content and footnote is probably desirable.

CommonMarkViewer creates empty space above it after each update when used in a `Grid`

gridbug.mp4

Minimal reproducible example with eframe:

use eframe::egui;
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};

fn main() {
    let native_options = eframe::NativeOptions::default();
    eframe::run_native(
        "Commonmark bug",
        native_options,
        Box::new(|_cc| Box::new(App::default())),
    )
    .expect("failed to run app");
}

#[derive(Default)]
struct App {
    cache: CommonMarkCache,
    content: String,
}

impl eframe::App for App {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            egui::Grid::new("my_grid")
                .num_columns(2)
                .striped(true)
                .show(ui, |ui| {
                    ui.label("row 1, col 1");
                    ui.label("row 1, col 2");
                    ui.end_row();
                    ui.label("row 2, col 1");
                    CommonMarkViewer::new("my_commonmark")
                        .max_image_width(Some(512))
                        .show(ui, &mut self.cache, &self.content);
                });
        });
        self.content += "a";
        ctx.request_repaint();
    }
}

Consider comrak as an alternative parser

Advantages

  • Better github flavoured support

Disadvantages

  • More dependencies
  • Slower than pulldown-cmark (don't know by how much)

Will probably keep both pulldown-cmark and comrak as a backend if it's not too much work.

Newline after list

I have noticed that when egui_commonmark renders the following md:

This is the list:
* The first item
	* First A nested item
	* First Another nested item
* The second item
	* Second nested item
		* A nested nested item
		* A nested nested another item
	* Second another nested
* The third item

A numbered list:

1. One
	1. One nested
	2. Two nested
		1. One one nested
		2. Two two nested
2. Two
3. Three

This is after the list.

we get this rendering with the line after the list attached to the list:

Screenshot 2022-10-07 at 10 35 30

to make it behave like github would be nice to render it like this:

Screenshot 2022-10-07 at 10 36 44

The change is small one more newline:

            pulldown_cmark::Tag::List(_) => {
                self.indentation -= 1;
                if self.indentation == -1 {
                    newline(ui);
                    newline(ui);
                }
            }

I understand this may be subjective though, what do you think?

Title to body vertical space missing when an image precedes the title

Consider the following markdown content (which can by copy-pasted in the hello_world.rs example):

### Title

![Demo recording]()

### Some text

This is some text.

### Some other text

This is some other text.

The expected result would be to have the same spacing between all titles and their respective bodies.

The actual result is a missing space between the Some text title and the This is some text body:

image

This phenomenon disappears if the (empty) image is removed. Note that this is not related to the image failing to display. Here is the "real world" context where I identified this issue:

image

(Note the missing space after Logging your own data.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.