Open willnationsdev opened 4 years ago
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.
I have written a cmark github module. It takes commonmark input and outputs html.
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:
@greenfox1505 is investigating markdown/commonmark to RichTextLabel via the module I posted.
https://github.com/fire/godot/tree/cmark was able do a patch
Wasn't able to do markdown/commonmark to richtextlabel as rich text.
My branch changed to https://github.com/v-sekai/godot/tree/cmark.
I really like how IntelliJ-based IDEs handle Markdown, in that you can edit it and/or view it:
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:
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
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:
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.
.
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:
WIP conversion to rendered content (will eventually have headers, online images, etc.):
Describe implementation detail for your proposal (in code), if possible:
/editor/markdown_editor.h
class for editing Markdown files and integrate it into the ScriptEditor./editor/markdown_renderer.h
class for rendering a Markdown file's contents.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.