Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full Markdown support for use in browsing, creating, and editing projects and addons #139

Open
willnationsdev opened this issue Oct 9, 2019 · 8 comments

Comments

@willnationsdev
Copy link
Contributor

willnationsdev commented Oct 9, 2019

Describe the project you are working on:

Designing solutions (either for editor changes or an addon) that involve browsing and displaying data regarding third-party addons.

Describe the problem or limitation you are having in your project:

Markdown README files are an industry-standard resource for sharing project information. Creators need to be able to edit and preview (render) them, and users need to be able to view (render) them. The Asset Library could then be refactored to render Markdown files (related to #12).

Describe how this feature / enhancement will help you overcome this problem or limitation:

  1. Allows users to employ more familiar and featureful technology than what Godot currently offers.
  2. Allows Godot to take advantage of a wealth of information already accessible on the Internet.
  3. Prevents users from needing to duplicate and maintain information between the Asset Library asset information (description) and the project's own README (the standard).
  4. Allows users to create, edit, and preview their own project's README directly from Godot rather than having to use a separate tool.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:

This would be similar to how VS Code's Extensions tab looks. Below is an example for #12 on how things could appear in the Asset Library if refactored to display Markdown files.

extensions-popular.

In fact, @fenix-hub's TextEditor plugin already has a dedicated viewport with an editor and previewer for Markdown files, so it would be an excellent starting place for creating an extension to the built-in ScriptEditor that does the same.

Raw .md file:

MD_FILE

WIP conversion to rendered content (will eventually have headers, online images, etc.):

MD2_FILE

Describe implementation detail for your proposal (in code), if possible:

  1. Add an /editor/markdown_editor.h class for editing Markdown files and integrate it into the ScriptEditor.
  2. Add an /editor/markdown_renderer.h class for rendering a Markdown file's contents.
  3. Update the ScriptEditor in these scenarios to have a Tab, CheckButton, or similar for editing versus previewing the currently opened .md file. (hide when not editing a .md file).
  4. Update the EditorFileSystem dock to display .md files and allow them to be selected/edited.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

Most of the community using any sort of addon (either creating OR using) would use this, so almost everyone.

Yes, this could be done as a plugin in script code. No, it would not be just a few lines. It would be a huge amount of work just to create a well-written editor and renderer pair.

Is there a reason why this should be core and not an add-on in the asset library?:

Yes. The ScriptEditor integration portion is something that can only properly be done with direct editor modifications in the source code.

Furthermore, we are talking about an industry-standard text format. It should be built into the editing experience for all users, without the need for a plugin.

@fire
Copy link
Member

fire commented Oct 9, 2019

From the module side there's two c based libraries for commonmark:

Edited:

See https://github.com/commonmark/cmark/blob/master/src/main.c#L75 for an example program.

@Calinou Calinou changed the title Add full Markdown support for use in browsing, creating, and editing projects and addons. Add full Markdown support for use in browsing, creating, and editing projects and addons May 4, 2020
@fire
Copy link
Member

fire commented Mar 28, 2021

I have written a cmark github module. It takes commonmark input and outputs html.

https://github.com/godot-extended-libraries/cmark_gfm

image

@fire
Copy link
Member

fire commented Mar 28, 2021

To write a walker for markdown to bbcode, this is how you do it.

void
usage_example(cmark_node *root) {
    cmark_event_type ev_type;
    cmark_iter *iter = cmark_iter_new(root);

    while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
        cmark_node *cur = cmark_iter_get_node(iter);
        // Do something with `cur` and `ev_type`
    }

    cmark_iter_free(iter);
}

I would create a String convert_bbcode(const String p_string); inside of the CommonmarkData class.

Edited:

https://www.systutorials.com/docs/linux/man/3-cmark/

@fire
Copy link
Member

fire commented Mar 28, 2021

@greenfox1505 is investigating markdown/commonmark to RichTextLabel via the module I posted.

@fire
Copy link
Member

fire commented Mar 29, 2021

https://github.com/fire/godot/tree/cmark was able do a patch

  1. markdown/common to html
  2. markdown/commonmark to text in a richtextlabel textbox

Wasn't able to do markdown/commonmark to richtextlabel as rich text.

@fire
Copy link
Member

fire commented Jun 18, 2022

My branch changed to https://github.com/v-sekai/godot/tree/cmark.

@joao-pedro-braz
Copy link

I really like how IntelliJ-based IDEs handle Markdown, in that you can edit it and/or view it:

  • Just editing it:
    image
  • Just viewing it:
    image
  • Doing both, editing and viewing it:
    image

If we were to add Markdown support to the Editor I think we should do something similar, maybe by (like in IDEA) having three buttons to toggle between modes at the top of the Script Editor, like in this mock-up:
image

@fire
Copy link
Member

fire commented Dec 23, 2023

I don't know what state this is in but https://github.com/V-Sekai/godot/tree/vsk-cmark-4.2 is my current work branch. I wasn't able to work on the rich text code but its salvageable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants